Sanitizing File Uploads

The HTML element <input type="file"> has a nice little browse feature that allows the user to browse for the file to be uploaded. However, it doesn't seem to be quite so well endowed when it comes to determining the file name to be assigned to the uploaded file. In the particular case with which I am dealing, the directory into which the uploaded file is to be placed is pre-determined, so that's not an issue. However, the name to be assigned to the uploaded file is another matter. At present, I am collecting that information in a separate <input type="text"> element which I have labeled "Save As:" This seems to leave a bit to be desired. It would seem to me that by far the most common case would be where the user wants to have the uploaded file share the same name on the remote system that it has on the local system. Hence, I think the best thing would be to somehow pre-populate my text field for collecting the file name with that name. I have no idea how to do that. If anyone has any suggestions, I'd love to hear them. I would also be interested in hearing about other approaches that others are using to address this issue.

Thanks for any input.

         ... doug

doug wrote:

...determining the file name to be assigned to the uploaded file. In the particular case with which I am dealing, the directory into which the uploaded file is to be placed is pre-determined... ... the user wants to have the uploaded file share the same name on the remote system that it has on the local system.
         ... doug

take a look at attachment_fu,

it deals with a lot of the annoying stuff you'll have to deal with.

and try to express your problems more concisely... the longer it is, the less people are going to read it, the less help you'll get.

Take care. Matthew Rudy.

take a look at attachment_fu,GitHub - technoweenie/attachment_fu: Treat an ActiveRecord model as a file attachment, storing its patch, size, content type, etc.

it deals with a lot of the annoying stuff you'll have to deal with.

Thanks. I was hoping that there would be some sort of simple way to achieve the desired result. In fact, I sort of half-way expected it based on my perception that it was likely an issue that was commonly encountered. Apparently that's not the case. I think I'll just have to live with having the user enter the file name.

and try to express your problems more concisely... the longer it is, the less people are going to read it, the less help you'll get.

Believe me, I understand the issue. On the one hand one can be criticized for being too verbose while on the other be criticized for being too brief and omitting relevant information. I agree with you that this post seemed a bit long. I wish that I had been able to shorten it; but, in my view there just wasn't anything I could omit.

Thanks for the input.

          ... doug