elena 56

I'm trying to specify a location for an <input type="file">

The case is that I'm expecting the file that is going to be uploaded to always have the same name (or a variation on this name).

Does anyone know if this is possible?

2 answers

Stephen 10
2
points

There is no way (for security reasons) to specify the default location of a file input. Otherwise a site could specify a hidden file input that defaults to a special file on the user's system, and hide it in a seeminly harmless form.

Answered about 7 years ago by Stephen
0
points

This depends completely on the language you are using on the server. The file input has very little or nothing to do with the location where the file is placed on the web server.

If you are using PHP, then you'll want to check out move_uploaded_file(). This will allow you to move the file to any location that the web server can write to. The second parameter of move_uploaded_file allows you to set a destination location and filename (almost anything you want).

If this is your first time doing uploads in PHP, you'll want to read the section of the PHP manual on Handling PHP Uploads.

Answered about 7 years ago by Darryl Hein
  • The OP is asking about defaulting the file input client side, not the processing of the file server side. Stephen about 7 years ago
  • What Stephen said. I'm using python (haven't used php in more than a year). I'm trying to include a suggestion at the client-side, obviously I can move the file anywhere I'd like server-side. elena about 7 years ago