1

I used a file upload form to upload files to my server. Then I echo $_FILES["file"]["tmp_name"] but it returns to me a location that does not seem to exist. eg /tmp/phpBparj4 is the output but there is no such file/folder in my /tmp folder. I have also checked for the appropriate permissions for the folder

My actual concern is move_uploaded_file($_FILES["file"]["tmp_name"],$target); which is not moving the uploaded file to the target location. I have also tried move_uploaded_file($_FILES["file"]["tmp_name"].$file_name,$target);

13
  • Did you check while the script was running or after? Commented Jun 15, 2012 at 5:11
  • I checked after the script finished running Commented Jun 15, 2012 at 5:11
  • 1
    Its a temp file, so its going to be deleted after the script finishes execution Commented Jun 15, 2012 at 5:13
  • 1
    Post some more code so we can see what's going on. Commented Jun 15, 2012 at 5:19
  • 2
    /var/www/projects/meme/upload/ does this exist and have proper permissions? Commented Jun 15, 2012 at 5:32

1 Answer 1

2

I am not sure if I understand right but why can't you specify the file folder location? i.e."

//set the right path from the server perspective $article_file_path = $_SERVER['DOCUMENT_ROOT']; // you should check for the file if it is/ or not already there (something like this) if (!file_exists($article_file_path ."/your_folder/file_subfolder/". $_FILES["my_file"]["name"])) { do something..... // then make your script upload the file exactly where you want it move_uploaded_file($_FILES["my_file"]["tmp_name"], $article_file_path ."/your_folder/file_subfolder/".$_FILES["my_file"]["name"]); // and the download link to the uploaded file would be something like this: echo "http://". $_SERVER["HTTP_HOST"] . "/files-article/".$_FILES["my_file"]["name"]"; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.