Reputation: 329
I am confuse how to upload file outside the www root file. Here, the www root file is in the C drive. But I want to upload the file in the Z drive of the server. I have following php script to upload file. Here, I have uploaded file in www/uploadApps/file but I have to upload file in the another folder that is outside the www root folder and which is in another drive.
move_uploaded_file($_FILES["file"]["tmp_name"], "file/" . $_FILES["file"]["name"]);
Upvotes: 2
Views: 5847
Reputation: 1231
Use an absolute path to point exactly where you want to store/retrieve the file from.
//Relative paths
$filePath = "file/" . $_FILES["file"]["name"];
$filePath = "/file/" . $_FILES["file"]["name"];
//Absolute paths
$filePath = "C:/www/uploadApps/file/" . $_FILES["file"]["name"];
$filePath = "Z:/file/" . $_FILES["file"]["name"];
Upvotes: 0
Reputation: 19251
instead of "file/"
, use an absolute path of where you want to file to be copied to.
for instance:
move_uploaded_file($_FILES["file"]["tmp_name"], "Z:/somefolder/" . $_FILES["file"]["name"]);
Upvotes: 2