I am using a file input to let the user upload a file which is to be attached later on at the controller level to an email. I am extending an application and the email class that already exists takes the path of the file as a string. Is there a way to pass the file from javascript (i know that browsers cant get full path for security reasons) and once i have the file on the aspnet web api 2 controller to get the filepath there?
I am not sure if code is really needed here so i will omit that for now unless requested for a specific reason.
Thanks in advance.
Related
I have little to, really no coding experience. Spare for a bit of HTML, CSS, and AppleScript However, I'm not sure where else to go in terms of insight on this question. Currently I am creating a Google Form for colleagues to submit work orders that will be recorded on a Google Spreadsheet.
But, I need to figure out how to write a script that will automatically add a specific file path next to files uploaded to the form.
For example, if a user uploaded a file named "061217_VideoAuthor_Slide1.mp4" instead of the Google Drive link (which is what is automatically populated with this file upload form option) I need that file name to be recorded and then it's cell needs to be changed from a Google Drive link to a specific file path
(Ex. /user/editor1/template/061217_VideoAuthor_Slide1.mp4)
Is there anyone that can point me to a sort-of specific tutorial or some documentation that could help me figure this out?
You can run logic every time the form is submitted that looks at the values in the sheet and augments them as needed.
Here's a walkthrough someone else put together:onFormSubmit
Your goal could be achieved by running a script every time a form is submitted, on certain schedule or by demand.
You will need to use JavaScript to get the file Id from the file URL, then get the file by using first getFileById(id) and getName() method from the Google Drive Service to get the file itself and its name respectively.
By the other side, instead or replacing the file URL I suggest you to add the file path to another column, just in case you need it later.
I need to have the functionality in the server side in order to hide the implementetion to the final user.
I didn't find a topic with this kind of solution.
I have a .js file with functions I use within the html5 file.
The js files are "called" in the html by using the script tag, but through the url the user can track them and see the .js file content. I don't want this to happen.
$getScript() does the job, but again the url can be cathched, thus the file content too. Much the same with $ajax function.
Everything work ok, but I want to hide the js content.
The .js file is something like this:
var x, x,....
function A(){...}
function B(){...}
and so on, I use A(), B() functions in the html.
Which is the best approach to get the content file from the server without doing the url visible?
Server: nodejs. (I send some json files through socket.io correctly, but I don't know how to achieve this other issue.
Thanks in advance, best!
If you are sending sensitive information to the client then you are doing it wrong. No matter if the client has the URL to the script, they will still be able to find it if they are determined as long as it is sent to their computer.
Find a different way to accomplish what you are trying to do without sending sensitive information to the client. It is not safe.
I'm building an uploader into my web page and trying to use flow.js as my uploading tool. On the server-side I have a WCF service with a generic handler as the target for my uploader. I do get the uploader to send a request to the handler, and when I inspect the contents, I get just the query string, but not the actual file content. Or at least I don't know where it is.
Looking at Fiddler I can see that the server call was a GET with a query string of parameters. I don't see the file content there either. What am I missing?
I was trying to use ng-flow which is based off of flow.js. A quick trip to flow.js github (https://github.com/flowjs/flow.js) and I realized that the GET is a test to get chunks for your files initialized, then the POST with the file chunks is sent. If you don't care for chunking, then set option 'testChunks' to false when doing your flow-init. Like this:
<html flow-init="{target:'SomeFileHandler.ashx',testChunks:false}">
Doing this you will only receive the POST with the file. Hope this helps someone in the future! I may edit this later when I decided to handle chunks. Also, I did find an ASP.NET MVC implementation that may be an interesting read here:
https://github.com/DmitryEfimenko/FlowJs-MVC
As the title states. I am looking to get the extension of the file, even if it is hidden via htaccess, for example:
.../whatever/index
Imagine it was a php file, is it possible to know that and extract it via JavaScript or jQuery?
Thanks in advance, can't find it anywhere. All I can find is people trying to actually hide the extension.
To achieve this you need some sever-side coding where you can request which file is behind the given path, so when you pass "/whatever/index" you server should returns 'whatever.php' and from that information you could extract the file extension.
Javascript itself doesn't know anything about what/how things are organized on the backend
I have a Python program that generates an html page for reporting results. The html page is saved in an output directory on disk alongside a javascript file that helps with dynamic table handling. I also save a JSON file to this output directory that I would like to read in with my javascript file. This JSON file has data from the Python run (saved dictionary) that I would like to be able to access. So in an output directory on disk I have:
C:/somedirectory/output/report.html
C:/somedirectory/output/tables.js
C:/somedirectory/output/data.json
All files have been created from my program.
My html page has a table with checkboxes and if those checkboxes are selected I would like to update a second table based on data saved in the JSON file. Thus I would like to open my html report in any browser and read in the JSON file as a javascript object.
I have been trying to use ajax and .getJSON but am getting the
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
I have searched and seen many similar problems but have not come across anything that quite fits what I need. Thoughts and a work around would be greatly appreciated. Thanks.
Update
Since everything is run locally on the client side I have decided to embed the JSON data (python dictionary) and javascript code directly into the html report output. This way the data is internally accessible and the html file can be passed around without dependency issues. The user with the answer I selected below has a link that eludes to this solution.
JavaScript runs on the client machine, hence it can only access files on the client machine using a special setup.
If you want it to read JSON on your server, you should use the path:
http://example.com/output/data.json
Better way would be to read/write JSON file from Python and then send the table data to JavaScript as in this answer: Send data from Python to Javascript (JSON)