0

I'm working with php on UNIX and I'm trying to get a real path from a browse button. I tried to use

echo $_FILES['nom_du_fichier']['temp_name']

but I got just the temporary path.

4

2 回答 2

0

The tmp_name given in the $_FILES array is just that: an intentionally temporary name generated on the server's filesystem for the uploaded file. If you want to keep it, you'll have to move the file yourself to its final intended destination on the server.

move_uploaded_file() is your best bet here. It has protections to ensure it doesn't act on a file that wasn't truly uploaded via a PHP-handled POST request.

If instead you want to get the full path of the file on the user's filesystem (that is, the location of the file on the user's hard drive), the browser doesn't send that information to the server. You'll need to use some client-side scripting to achieve that. However I can't imagine why such information would be useful for a web app to know.

于 2013-03-31T03:06:30.493 回答
0

Normally you can not get system path in $_FILES variable. Because $_FILES variable of the PHP always contains information of the files which get uploaded from your HTML page to your webserver.

The reason becuase of you are not getting location of client machine file path is security. Just think as common scenario in which you are user of the website. So you never want your internal file structure to be disclosed. In all mordern browser they do not expose client location even from JavaScript.

If you really need complete file location from client browser then you need to create form using flash or action script

于 2013-03-31T03:14:49.070 回答