I have been searching everywhere to find out how to implement the html 5 drag and drop file upload thing and I am still stuck with nothing. I tried BalusC's solution on how to upload the file to a servlet (HTML5 File Upload to Java Servlet). It works just fine, except that I can't send anything else along with the file. What I'm trying to implement is a form which takes both a file and a textual description of what the file is all about, like a "comment". When the user drags and drops the file, enters the comment and clicks "submit", the file must be uploaded to the server, using Servlets. With BalusC's code, the servlet is invoked, but if I try to display the "comment" (which I appended to the formData object), I get a null value. How can I append the comment to the data I send too? I like Vap0r's implementation too (HTML5 drag and drop and multiple file upload), but it doesn't work for me either. Help?
Related
I am writing a Django application where I have a HTML form to get a few inputs from the user. One of the inputs is an (optional) attachment file. The user is also provided with option to edit the form at some point in future.
When the user chooses to edit the form, the Django view returns the ModelForm and in the template I populate all the fields. But I am not able to populate the attachment in the file input tag. However, I can see that the form object has the attachment in it.
I found a few SO questions which asks for attaching a new file using scripts. And that is not possible due to security reasons. But I am looking for populating the file returned by the server on HTML page.
Is there a way to populate attached files with input tags?
No you can't do that. Instead what you do is provide a link to existing file and a separate input box for a new file in case the user needs it.
My use case is this:
User has a file to upload.
File is validated and various metadata is returned to the user.
User now decides whether to commit the file of not.
Part three is the new bit. Currently the user just uploaded the file, it's committed and information about what happened is returned. I'm having to put in the middle bit.
I've added a boolean supressCommit that allows the file to be uploaded, the information to be gathered but then the committing not to take place.
Now I have a problem, I don't want to introduce state on the server and store the file contents there. That would open up a whole other can of worms. This means that if the user clicks the commit button on the confirmation page I have to upload the file again, this time with suppressCommit set to false.
It's not pretty, but acceptable. My problem is this though, how can I re-upload the original file without the user having to go through selecting the file again?
My options seem to be:
Pass the file contents back in the model.
Not great as now I'll have to somehow put those into the HTTP request manually so they show in the RequestContext in the Request.Files collection.
Pass back the original file path.
If I do this then is it possible to pragmatically set the File input box to something or is that a security violation?
I am writing a Perl script that is parsing a file into an HTML table which essentially contains classes and their information. The main objective of the script is for the user to check which classes he needs and the script will read which checkbox states are TRUE and only include those when creating a file that is like the original. Currently, I'm at the point where the HTML file opens in the users default browser, but if I check some of the checkboxes and save the webpage it doesn't save their states (tried it in Chrome and IE). Is there anyway to do this so that when the file is saved the user can hit enter in the program and have it do its conversion?
I am facing problem in HTML 5. I need to statically load data into web page from local saved files. Up to now, I have been only able to load data via < input type="file" id="fileinput" / > but I want to load data from static location, which never changes. How to do that? And is there any way how to determine, whether some local file was changed from previous version?
Thanks
no, this isn't possible if by 'local', you mean a file at /home/waypoint/somefile.txt. You can make a 'link' with the filesystem api (if you selected it in an input field, for instance), which is valid to do computations with it (to read it, write to it, display it in img,etc). But it is deleted/unvalid, as soon as the window closes. If you could just magically "read" any local file via javascript which resides on the file system, who would stop google to read out your /etc/passwd file?
if your local computer is also your server and therefor your server-side code has access to the local file /home/waypoint/somefile.txt, your app can get it via ajax. Checking if the file exists, would be done the same way.
I have a working s3 uploader in actionscript that uses the FileReference class so a user can browse for files to upload when he/she clicks on the upload button.
I have a web application and I want the user to have his/her configuration saved to s3 as an XML file when they hit the save button, so the "save" button will trigger the upload. However, i cant figure out a way to add the XML file to the FileReference variable I create. I was looking at the File class but that appears to be only usable in AIR.
Is it possible to create a FileReference object based off of an XML file that actionscript creates within the application without browsing for a file using FileReference.browse(); ?
Thanks
The answer to my original question is "no". According to this article by Mike Chambers, you cant.
It is apparently a sandbox issue so that a malicious flash program will not be able to do anything related to saving files without a users permission.