move-uploaded-file cannot find uploaded file in tmp

Problems with the Windows version of XAMPP, questions, comments, and anything related.

move-uploaded-file cannot find uploaded file in tmp

Postby tbirchmire » 22. March 2006 12:43

When I attemp to use move-uploaded-file (WinXP & XAMPP for Windows Version 1.5.0-pl1), I get the following response)
The printout of the $_FILE below shows that TMP_NAME is populated correctly and there is no error.
Any and all help and suggestions appreciated.
Regards, Tom Birchmire

Target Path upload/2gf70098p.jpg
Upload Location tmp_name = C:\xampp\xampp\tmp\php8.tmp

Array contents
NAME = 2gf70098p.jpg
TYPE = image/jpeg
SIZE = 27599
TMP_NAME= C:\xampp\xampp\tmp\php8.tmp
ERROR0

Array ( [uploadedfile] => Array ( [name] => 2gf70098p.jpg [type] => image/jpeg [tmp_name] => C:\xampp\xampp\tmp\php8.tmp [error] => 0 [size] => 27599 ) )
Warning: move_uploaded_file(upload/2gf70098p.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\xampp\xampp\htdocs\bmwstuff\upload\uploader.php on line 23

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampp\xampp\tmp\php8.tmp' to 'upload/2gf70098p.jpg' in C:\xampp\xampp\htdocs\bmwstuff\upload\uploader.php on line 23
There was an error uploading the file, please try again!

Code:

<?php

$target_path = "upload/";
echo $target_path ."\n\r \n\r <br><br>" ;


$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

echo " Target Path " . $target_path . "\r\n <br>" ;
echo "Upload Location tmp_name = " . $_FILES['uploadedfile']['tmp_name'] . "<br>" ;

echo "Array contents <br /> " ;

echo "NAME = " . $_FILES['uploadedfile']['name'] ." <br />" ;
echo "TYPE = " . $_FILES['uploadedfile']['type'] ." <br />" ;
echo "SIZE = " . $_FILES['uploadedfile']['size'] ." <br />" ;
echo "TMP_NAME= " . $_FILES['uploadedfile']['tmp_name'] ." <br />" ;
echo "ERROR" . $_FILES['uploadedfile']['error'] ." <br />" ;
print_r($_FILES) . "<br /> ";

//echo "Upload Location tmp_name = " . $_FILES['userfile']['upload_tmp_dir'] . "<br>" ;

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}


?>
tbirchmire
 
Posts: 2
Joined: 16. September 2004 02:34

Postby Wiedmann » 22. March 2006 12:51

$target_path = "upload/";

You should use a full and valid path.
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

move-uploaded-file problem fixed

Postby tbirchmire » 22. March 2006 15:49

Using the full path corrected the problem.
Thanks Tom Birchmire 8)
tbirchmire
 
Posts: 2
Joined: 16. September 2004 02:34


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 104 guests