mistermister Posted March 19, 2007 Share Posted March 19, 2007 when im trying to upload a file i get this error message and i dont know why i think every thing is ok with my code there is the error and the the code Warning: move_uploaded_file(3/New Text Document.txt) [function.move-uploaded-file]: failed to open stream: No such file or directory in /var/www/localhost/inside/addCustomerDocumentDone.php on line 31 $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { echo "<html> <head> <title>Create a task</title> <link rel='stylesheet' type='text/css' href='CRMstyle.css' /> </head> <body> <h5>File is valid, and was successfully uploaded.</h5> . . . . . and this is my upload dir $uploaddir = "/var/www/localhost/inside/customersdocs/"; Link to comment https://forums.phpfreaks.com/topic/43344-error-when-trying-to-upload-a-file/ Share on other sites More sharing options...
r-it Posted March 19, 2007 Share Posted March 19, 2007 why is the $uploaddir at the bottom, it should be initialised before the actual upload Link to comment https://forums.phpfreaks.com/topic/43344-error-when-trying-to-upload-a-file/#findComment-210478 Share on other sites More sharing options...
mistermister Posted March 19, 2007 Author Share Posted March 19, 2007 yes i know declared it in a decleration file and i have included it in this file Link to comment https://forums.phpfreaks.com/topic/43344-error-when-trying-to-upload-a-file/#findComment-210479 Share on other sites More sharing options...
r-it Posted March 19, 2007 Share Posted March 19, 2007 does the "customersdocs" directory exist and do you have read and write permissions for it? Link to comment https://forums.phpfreaks.com/topic/43344-error-when-trying-to-upload-a-file/#findComment-210481 Share on other sites More sharing options...
mistermister Posted March 19, 2007 Author Share Posted March 19, 2007 this is the permission for this directory drwxr-xr-x 5003 root root 120184 Feb 26 18:27 customersdocs Link to comment https://forums.phpfreaks.com/topic/43344-error-when-trying-to-upload-a-file/#findComment-210484 Share on other sites More sharing options...
r-it Posted March 19, 2007 Share Posted March 19, 2007 try giving it a new filename(use some session variable or something) like: $filename = $_SESSION['username']. substr($_FILES['userfile']['name'], -4); $uploaddir = "customersdocs/"; $rez = move_uploaded_file($_FILES['fileUpload']['tmp_name'], $tempres); if($rez) { ...... } or perhaps try this: $uploaddir = "customersdocs/"; thats if your file is within inside Link to comment https://forums.phpfreaks.com/topic/43344-error-when-trying-to-upload-a-file/#findComment-210487 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.