MishieMoo Posted August 3, 2008 Share Posted August 3, 2008 Hey all, I have a file upload script that I've used before, but for some reason now it's not working. I'm not getting any errors, even in the $_FILES array. It doesn't move the uploaded file, which is the only error that appears to happen. Here's my code: <?php $max_image_size = '15360'; // this has to be in bytes $max_image_width = '80'; // in pixels $max_image_height = '80'; $image_accepted=array('image/jpg','image/gif','image/png'); if ($_FILES['url']['size'] > $max_image_size){ //If the file size is greater than 500000b $error='Your file size must be less than <strong>15kb</strong>!<br />'; error_msg($error); exit(); } if (!in_array($_FILES['url']['type'], $image_accepted)) { $error='Image is not one of the accepted types.'; error_msg($error); exit(); } $dim=getimagesize($_FILES['url']['tmp_name']); if ($dim[0] > $max_image_width || $dim[0] > $max_image_height) { $error='Image uploaded is too big.'; error_msg($error); exit(); } $folder = "/items/"; $newimagename=$folder . $_FILES['url']['name']; if(move_uploaded_file($_FILES['url']['temp_name'], $newimagename)) { $url=$folder . basename($_FILES['url']['name']); } else{ print_r($_FILES); echo$newimagename; $error="File could not be uploaded.<br />"; error_msg($error); exit();} } $addnew = mysql_query("INSERT INTO item_list(name,description,category,amount,url,shop_price,rarity) VALUES ('$name','$desc','$cat','$amount','$url','$price','$rarity')") or die(mysql_error()); if($addnew){ for($i=0;$i<$amount; $i++){ $additems=mysql_query("INSERT INTO items(category,name)VALUES('$cat','$name')"); } echo'Item '.$name.' has been created!'; }?> Any help would be appreciated. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/117984-solved-file-upload-script-not-working/ Share on other sites More sharing options...
jjmusicpro Posted August 3, 2008 Share Posted August 3, 2008 most likely having same problem im having http://www.phpfreaks.com/forums/index.php/topic,210123.0.html check your error log Quote Link to comment https://forums.phpfreaks.com/topic/117984-solved-file-upload-script-not-working/#findComment-606975 Share on other sites More sharing options...
MishieMoo Posted August 3, 2008 Author Share Posted August 3, 2008 I checked my error log, and the only errors from today don't come from that page. Unfortunately, it's a different problem. Quote Link to comment https://forums.phpfreaks.com/topic/117984-solved-file-upload-script-not-working/#findComment-606980 Share on other sites More sharing options...
PFMaBiSmAd Posted August 3, 2008 Share Posted August 3, 2008 Start by turning on full php error reporting to find out why the function call is failing. Add the following two lines immediately after your first opening <?php tag - ini_set ("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/117984-solved-file-upload-script-not-working/#findComment-606984 Share on other sites More sharing options...
MishieMoo Posted August 3, 2008 Author Share Posted August 3, 2008 Hahaha that makes me feel really stupid. Apparently I didn't have that turned on. Anyways, I was spelling tmp_name wrong o.O ::headdesk:: Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/117984-solved-file-upload-script-not-working/#findComment-606986 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.