views:

10

answers:

1

Hi, I have been monitoring the parameters a website receives when a file is uploaded (via an input type="file"). Surprisingly, the parameter and its value were looking like this :

parameter: upfile

value: filename="this is the name of the uploaded file.png" Content-type: image/x-png

Now in this POST request to the server page, the file name and its type is passed into a parameter, but what about the path to that filename? Where is that path stored so that the server page can upload the file at the good location?

Also, I would like to know if it would be possible by any way to specify a path, NOT to the input type="file" since its impossible, but to the server (though this question probably depends a lot on how the server-side page is scripted).

Thank you for your answers.

A: 

I usually use PHP, so I will be referring to it in my explanation here.

When a file is uploaded, it is placed in a temporary directory /tmp.

PHP provides a means to move the file from the temporary location to where you want it to be via a function called move_uploaded_file($filename, $path_to_move_to);

In PHP, the information such as filesize, filename about the uploaded file(s) are not in the array with all the $_POST information, but is instead placed in the $_FILES array.

If you have an input: <input type="file" name="userfile" />, you can move the file by doing move_uploaded_file($_FILES['userfile']['name'], '/dir/to/where/i/want_files_to_go');

I think Perl can deal with file uploads similarly, but it's been a while since I touched a Perl file uploader.

phsource
Thank you for your answer, its exactly what I wanted.
Sheavi