LiamProductions Posted August 19, 2007 Share Posted August 19, 2007 Hey. I've made a simple upload script... and its not giving me any errors or uploading the file or even telling me the file name <?php if($_FILES['file']['size'] < 20000) { if($_FILES['file']['error'] > 0) { echo "We have found a error: " . $_FILES['file']['error'] . "<br />"; } else { echo "File: " . $_FILES['file']['name'] . "<br />"; echo "Type: " . $_FILES['file']['type'] . "<br />"; echo "Size: " . $_FILES['file']['size'] . "<br />"; if(file_exists("upload" . $_FILES['file']['name'])) { echo "Sorry, " . $_FILES['file']['name'] . "already exists. "; } else { move_uploaded_file($_FILES['file']['tmp_name'], "upload/" . $_FILES['file']['name']); echo "Stored in: http://www.liam-monks.com/upload/" . $_FILES['file']['name']; } } } else { echo "Invalid File!"; } ?> I don't see the error anywhere and its providing no error: Full page result: File: Type: Size: Stored in: http://www.liam-monks.com/upload/ Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/ Share on other sites More sharing options...
MadTechie Posted August 19, 2007 Share Posted August 19, 2007 try this. <?php echo "<pre>";print_r($_FILES); if($_FILES['file']['size'] < 20000) { if($_FILES['file']['error'] > 0) { echo "We have found a error: " . $_FILES['file']['error'] . "<br />"; }else{ echo "File: " . $_FILES['file']['name'] . "<br />"; echo "Type: " . $_FILES['file']['type'] . "<br />"; echo "Size: " . $_FILES['file']['size'] . "<br />"; if(file_exists("upload" . $_FILES['file']['name'])) { echo "Sorry, " . $_FILES['file']['name'] . "already exists. "; }else{ move_uploaded_file($_FILES['file']['tmp_name'], "upload/" . $_FILES['file']['name']); echo "Stored in: http://www.liam-monks.com/upload/" . $_FILES['file']['name']; } } }else{ echo "Invalid File!"; } ?> whats returned Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-327999 Share on other sites More sharing options...
LiamProductions Posted August 19, 2007 Author Share Posted August 19, 2007 The code you just sent outputs: Array ( ) File: Type: Size: Stored in: http://www.liam-monks.com/upload/ Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328010 Share on other sites More sharing options...
MadTechie Posted August 19, 2007 Share Posted August 19, 2007 POST your form.. as its not sending and $_FILE data Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328013 Share on other sites More sharing options...
LiamProductions Posted August 19, 2007 Author Share Posted August 19, 2007 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <meta name="author" content="PHP Designer 2007"> <title>Untitled 2</title> </head> <body> <form method="post" action="uploadfinish.php"> File: <input type="file" name="file"> <input type="submit" value="Upload!"> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328014 Share on other sites More sharing options...
MadTechie Posted August 19, 2007 Share Posted August 19, 2007 change <form method="post" action="uploadfinish.php"> File: <input type="file" name="file"> <input type="submit" value="Upload!"> to <form method="post" action="uploadfinish.php" enctype="multipart/form-data"> File: <input type="file" name="file"> <input type="submit" value="Upload!"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328021 Share on other sites More sharing options...
plutomed Posted August 19, 2007 Share Posted August 19, 2007 Have you set the permissions for the folder to be accessed to 777? Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328024 Share on other sites More sharing options...
LiamProductions Posted August 19, 2007 Author Share Posted August 19, 2007 Have you set the permissions for the folder to be accessed to 777? Not sure what you mean... AND... i've changed the form to what you said. Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328034 Share on other sites More sharing options...
plutomed Posted August 19, 2007 Share Posted August 19, 2007 I think it's called chmod or something like that, where is your hosting? Or do you host your self? Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328036 Share on other sites More sharing options...
LiamProductions Posted August 19, 2007 Author Share Posted August 19, 2007 I think it's called chmod or something like that, where is your hosting? Or do you host your self? My hosting is at http://www.apthost.com Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328043 Share on other sites More sharing options...
plutomed Posted August 19, 2007 Share Posted August 19, 2007 Do you connect to upload your files via ftp or online cp? Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328046 Share on other sites More sharing options...
LiamProductions Posted August 19, 2007 Author Share Posted August 19, 2007 Connect? Do you mean view my files? cPanel 11 Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328055 Share on other sites More sharing options...
MadTechie Posted August 19, 2007 Share Posted August 19, 2007 whats the problem now? you getting the same results? as for access rights.. the data isn't being sent yet so theirs nothing to write! Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328061 Share on other sites More sharing options...
plutomed Posted August 19, 2007 Share Posted August 19, 2007 Oh ok so what is the name of the upload field? Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328068 Share on other sites More sharing options...
LiamProductions Posted August 19, 2007 Author Share Posted August 19, 2007 Oh ok so what is the name of the upload field? Huh? And why isnt the data being recieved? Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328082 Share on other sites More sharing options...
MadTechie Posted August 19, 2007 Share Posted August 19, 2007 whats being displayed on the page ? can you also repost the form and the php code again (in code tags #) also i assume the filename of the php code is uploadfinish.php Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328084 Share on other sites More sharing options...
LiamProductions Posted August 19, 2007 Author Share Posted August 19, 2007 Sure... upload.html: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <meta name="author" content="PHP Designer 2007"> <title>Untitled 2</title> </head> <body> <form method="post" action="uploadfinish.php" enctype="multipart/form-data"> File: <input type="file" name="file"> <input type="submit" value="Upload!"> </form> </body> </html> AND... uploadfinish.php <?php echo "<pre>";print_r($_FILES); if($_FILES['file']['size'] < 20000) { if($_FILES['file']['error'] > 0) { echo "We have found a error: " . $_FILES['file']['error'] . "<br />"; }else{ echo "File: " . $_FILES['file']['name'] . "<br />"; echo "Type: " . $_FILES['file']['type'] . "<br />"; echo "Size: " . $_FILES['file']['size'] . "<br />"; if(file_exists("upload" . $_FILES['file']['name'])) { echo "Sorry, " . $_FILES['file']['name'] . "already exists. "; }else{ move_uploaded_file($_FILES['file']['tmp_name'], "upload/" . $_FILES['file']['name']); echo "Stored in: http://www.liam-monks.com/upload/" . $_FILES['file']['name']; } } }else{ echo "Invalid File!"; } ?> and the result of the page is: Array ( [file] => Array ( [name] => tgpamandabynes.jpg [type] => image/jpeg [tmp_name] => /tmp/phpr3RLIq [error] => 0 [size] => 28375 ) ) Invalid File! Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328088 Share on other sites More sharing options...
MadTechie Posted August 19, 2007 Share Posted August 19, 2007 file is too big if($_FILES['file']['size'] < 20000) [file] => Array ( [name] => tgpamandabynes.jpg [type] => image/jpeg [tmp_name] => /tmp/phpr3RLIq [error] => 0 => 28375 ) change to if($_FILES['file']['size'] < 2000000) Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328090 Share on other sites More sharing options...
LiamProductions Posted August 19, 2007 Author Share Posted August 19, 2007 This is the output now: File: healthbar.png Type: image/png Size: 270 Warning: move_uploaded_file(upload/healthbar.png) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/liam/public_html/uploadfinish.php on line 17 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpfOcFhM' to 'upload/healthbar.png' in /home/liam/public_html/uploadfinish.php on line 17 Stored in: http://www.liam-monks.com/upload/healthbar.png Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328113 Share on other sites More sharing options...
MadTechie Posted August 19, 2007 Share Posted August 19, 2007 Right.. NOW were on the access rights you need to change the access rights(permissions) to the upload folder find the folder and click set permissions (or something) your probably see 9 tick boxes, tick all of them click apply/update/save Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328120 Share on other sites More sharing options...
LiamProductions Posted August 19, 2007 Author Share Posted August 19, 2007 Thanks! It works now Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328124 Share on other sites More sharing options...
phpSensei Posted August 19, 2007 Share Posted August 19, 2007 edit: DELETE POST PLEASE Quote Link to comment https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328142 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.