iPixel Posted September 12, 2007 Share Posted September 12, 2007 Any ideas... my server setting seem to be fine as to allowing img uploads .. Send form : <html> <body> <form enctype="multipart/form-data" action="upload.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000" /> Choose a file to upload: <input name="uploaded_file" type="file" /> <input type="submit" value="Upload" /> </form> </body> </html> The upload script : <?php //Сheck that we have a file if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) { //Check if the file is JPEG image and it's size is less than 350Kb $filename = basename($_FILES['uploaded_file']['name']); $ext = substr($filename, strrpos($filename, '.') + 1); if (($ext == "jpg") && ($_FILES["uploaded_file"]["size"] < 350000)) { //Determine the path to which we want to save this file $newname = dirname(__FILE__).'/upload/'.$filename; //Check if the file with the same name is already exists on the server if (!file_exists($newname)) { //Attempt to move the uploaded file to it's new place if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) { echo "It's done! The file has been saved as: ".$newname; } else { echo "Error: A problem occurred during file upload!"; } } else { echo "Error: File ".$_FILES["uploaded_file"]["name"]." already exists"; } } else { echo "Error: Only .jpg images under 350Kb are accepted for upload"; } } else { echo "Error: No file uploaded"; } ?> The Bloody ERROR : Warning: move_uploaded_file(c:\Inetpub\wwwroot\upload/upload/334475.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in c:\Inetpub\wwwroot\upload\upload.php on line 16 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\PHP\uploadtemp\php32.tmp' to 'c:\Inetpub\wwwroot\upload/upload/334475.jpg' in c:\Inetpub\wwwroot\upload\upload.php on line 16 Error: A problem occurred during file upload! Quote Link to comment https://forums.phpfreaks.com/topic/69068-solved-failed-to-open-stream/ Share on other sites More sharing options...
kireol Posted September 12, 2007 Share Posted September 12, 2007 hrmmm. something to check on, but the directory slashes are / and \ i'm not sure how windows handles that. Quote Link to comment https://forums.phpfreaks.com/topic/69068-solved-failed-to-open-stream/#findComment-347179 Share on other sites More sharing options...
iPixel Posted September 12, 2007 Author Share Posted September 12, 2007 Noticed that myself as well... no biggie, still same issue thanks though ! Quote Link to comment https://forums.phpfreaks.com/topic/69068-solved-failed-to-open-stream/#findComment-347183 Share on other sites More sharing options...
kireol Posted September 12, 2007 Share Posted September 12, 2007 ok, hrmm. next try echoing echo "$_FILES['uploaded_file']['tmp_name']"; and make sure that that 1)that variable has the correct data and 2)the data that the variable is referencing exists as a file in the correct directory. I'm at work, so I can't run scripts, just using the compiler in my mind Quote Link to comment https://forums.phpfreaks.com/topic/69068-solved-failed-to-open-stream/#findComment-347185 Share on other sites More sharing options...
iPixel Posted September 12, 2007 Author Share Posted September 12, 2007 the echo returns : C:\PHP\uploadtemp\php41.tmp now i went to the server and to that directory and did not find a php41.tmp, could that be the cause... when i upload i simply try to upload a small jpg file from my work desktop... I placed the file i wanted to upload into the server directory where the script is supposed to upload the file to... and the script worked and said "File already exists..." so its working but for some reason the physical upload is where the issue is .. i think. Perhaps im wrong and PHP might not have permissions to read and write to the folder its trying to copy the file to. Where do i check and change that if needbe ? Quote Link to comment https://forums.phpfreaks.com/topic/69068-solved-failed-to-open-stream/#findComment-347192 Share on other sites More sharing options...
iPixel Posted September 12, 2007 Author Share Posted September 12, 2007 i check my info.php page.. upload_max_filesize 2 M 2M upload_tmp_dir C:\PHP\uploadtemp C:\PHP\uploadtemp Quote Link to comment https://forums.phpfreaks.com/topic/69068-solved-failed-to-open-stream/#findComment-347211 Share on other sites More sharing options...
kireol Posted September 12, 2007 Share Posted September 12, 2007 I dont have access to a computer right now that runs PHP. I'm at a loss. maybe someone else can chime in? Quote Link to comment https://forums.phpfreaks.com/topic/69068-solved-failed-to-open-stream/#findComment-347216 Share on other sites More sharing options...
iPixel Posted September 12, 2007 Author Share Posted September 12, 2007 Fixed it .. it was a permissions thing i had 777 but i didnt notice i had admin selected .. for "everyone" the write was not checked. Bah always the little stupid mistakes... non the less thank you very much for your help. Quote Link to comment https://forums.phpfreaks.com/topic/69068-solved-failed-to-open-stream/#findComment-347261 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.