narjis Posted January 30, 2011 Share Posted January 30, 2011 I am using xammp with FileZilla running on it. I've changed my php.ini settings to "C:/xxx/tmp" directory but am unable to upload a file. Th cod is running but it dos not seem to upload the temporary fil. Plase somebody help me. ALso my form in upload.html has <form action="upload_file.php" method="post" enctype="multipart/form-data"> Quote Link to comment https://forums.phpfreaks.com/topic/226092-uploading-files/ Share on other sites More sharing options...
Pikachu2000 Posted January 30, 2011 Share Posted January 30, 2011 What makes you think it doesn't upload the file? What have you done to debug it? Some code, posted within . . . BBCode tags would be helpful, I'm sure. Quote Link to comment https://forums.phpfreaks.com/topic/226092-uploading-files/#findComment-1167141 Share on other sites More sharing options...
narjis Posted January 30, 2011 Author Share Posted January 30, 2011 <body> <form action="upload_file.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { if(is_uploaded_file($_FILES["file"]["name"])) { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } } else { echo "Invalid file"; } Quote Link to comment https://forums.phpfreaks.com/topic/226092-uploading-files/#findComment-1167168 Share on other sites More sharing options...
jcbones Posted January 30, 2011 Share Posted January 30, 2011 You could try a good `ole: echo '<pre>'; print_r($_FILES); echo '</pre>'; At the top. Quote Link to comment https://forums.phpfreaks.com/topic/226092-uploading-files/#findComment-1167172 Share on other sites More sharing options...
narjis Posted January 31, 2011 Author Share Posted January 31, 2011 whn I run with print_r command thn it shows the following path but I cannot view th php2C.tmp file in the folder. Also move_uploaded_file() command also gives the same warning as unable to open file stream no such file exists. Please help Array ( [file] => Array ( [name] => w6.jpg [type] => image/jpeg [tmp_name] => C:\xxx\anonymous\php2C.tmp [error] => 0 => 8268 ) ) Quote Link to comment https://forums.phpfreaks.com/topic/226092-uploading-files/#findComment-1167558 Share on other sites More sharing options...
Pikachu2000 Posted January 31, 2011 Share Posted January 31, 2011 Any errors when you try the upload? Any other information that might be helpful in diagnosing this? Quote Link to comment https://forums.phpfreaks.com/topic/226092-uploading-files/#findComment-1167564 Share on other sites More sharing options...
jcbones Posted January 31, 2011 Share Posted January 31, 2011 This line: if(is_uploaded_file($_FILES["file"]["name"])) { For proper working' date=' the function is_uploaded_file() needs an argument like $_FILES['userfile'']['tmp_name'], - the name of the uploaded file on the client's machine $_FILES['userfile']['name'] does not work. Should probably be: if(is_uploaded_file($_FILES["file"]["tmp_name"])) { Or, if(move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"])) { echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } Quote Link to comment https://forums.phpfreaks.com/topic/226092-uploading-files/#findComment-1167567 Share on other sites More sharing options...
narjis Posted January 31, 2011 Author Share Posted January 31, 2011 Only the following errers Warning: move_uploaded_file(upload/w5.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\xxxx\xxxx\samples\Upload_file.php on line 37 and Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampp\anonymous\php69.tmp' to 'upload/w6.jpg' in C:\xampp\xxx\samples\Upload_file.php on line 26 each time it gives a random nam.tmp Quote Link to comment https://forums.phpfreaks.com/topic/226092-uploading-files/#findComment-1167571 Share on other sites More sharing options...
jcbones Posted January 31, 2011 Share Posted January 31, 2011 Make sure C:\xxxx\xxxx\samples\upload\ exists. Quote Link to comment https://forums.phpfreaks.com/topic/226092-uploading-files/#findComment-1167583 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.