Show previously attached file in HTML form while editing - html

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.

Related

Select and file input form data in flask

So I have this flask website that I can upload files to but I want them to be uploaded into separate folders depending on a drop down list in the same form.
So basically I want it to function that if I pick option "level1" in the form, the file should be uploaded to the level1 subdirectory and if I pick "level2" it should upload to the level2 directory etc.
I started out by adding both the select and input file into the same form but only the file upload is happening and I don't seem to get any value from the select part of the form when printing the details of request.form, request.values, request.data etc.
Likely there is something I am missing with the logic here, perhaps I cannot use select int the same form as file input due to the enctype?
I am not seeing the select part of the form data in the browser either when looping at the dev console.

How to convert an excel cell into a HTML file?

I would like to ask for some help (again), here's my context : I'm trying to create an Excel Worksheet that I can add some coordinates and generate an html page with a map using Google Maps API and his markers.
I have successfully created a macro that get the data from my SQL Server and that also create the html structure (tags,header,body,etc.).
Here's my problem : There is a way to create a macro that get the value of my cell (that contains the HTML structure) and transform it into a HTML page? (Also, I have to be able to save this file into a directory, because it will be used by other users)
Thanks in advance!
Your question basically boils down to this... How do I read the value from a cell and save it to a text file? After all, an HTML file is just a text file with the .html file extension.
So, I assume you already know how to read the value of a cell. Now comes the question of how to write that string to a text file, and that part of the question has been answered before, both in MSDN articles that you can find via a Google search, and right here on SO...
https://stackoverflow.com/a/11503299/1246574
Hope this helps. Sometimes solving a seemingly complex problem is about breaking the question into simplified parts.

HTML5 drag and drop file, and upload on button click

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?

Saving HTML with Checkbox states

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?

Restoring the value of a input type=file after failed validation

I have a form with several inputs that deal with files. The javascript validation is pretty good at checking to make sure that everything is good, but some things require PHP to inspect (like the file's mime type), and sometimes it will get rejected.
The problem is, when I send the user back to the form, I can repopulate all the data that they had originally input, except the inputs with the type of file. Firefox doesn't provide the absolute file path so I can't just copy in a file path to the input.
What can I do to repopulate the input type=file form elements?
You cannot populate the file input, to do so would be a serious security problem.
Instead, store the uploaded content on the server and store an id that you can use to reference it in a hidden input.
Clean the files up automatically after they reach a certain age, and provide a means for the user to change their mind about what file they want to upload (e.g. a checkbox (checked by default) for each file being stored on the server for upload)