iPixel Posted October 4, 2007 Share Posted October 4, 2007 So i have this script ! as simple as it gets to upload an image. I got it working all fine with no errors or anything ... uploaded the image just fine, and inserted into the DB just as well. I've ran the script on a few occasions with no problems and today i get in, run the script and voila ! WONT WORK ! what is that about. The only change to the server was a cPanel update, as far as i know! If you have any clue why this may be please toss it my way ! Thanks The Script ! <? include('../connect2db.php'); $action = isset($_POST['action']) ? $_POST['action'] : null; if (!is_null($action)) { $action = $_POST['action']; } if($action == "insert") // IF INSERT THEN UPLOAD THE IMAGE THAT WAS POSTED TO THIS POINT { $userfile_name = $_FILES['image']['name']; // filename $userfile_tmp = $_FILES['image']['tmp_name']; // temp filename $userfile_size = $_FILES['image']['size']; // file size $userfile_type = $_FILES['image']['type']; // file type... jpg, gif, etc... $placefiledir = 'upload/newsletters/'; // Directory where image will be uploaded to $prod_img = $placefiledir . $userfile_name; // path/imgname.jpg if (isset($_FILES['image']['name'])) // if the array isnt empty upload the file { if(move_uploaded_file($userfile_tmp, $prod_img)) // Upload the image file { //print_r($_FILES); // prints out $_FILES array content //echo $userfile_name . "<BR>"; $takeoffext = substr($userfile_name, 0, -4); $htmlfilename = $takeoffext . ".HTML"; //echo $htmlfilename; $query = "INSERT INTO e_newsletters (htmlfile, thumbfile, timestamp, date) VALUES ('$htmlfilename', '$userfile_name', CURRENT_TIMESTAMP(), now())"; $sql = mysql_query($query) or die('Error with e_newsletter query ' . mysql_error()); ?><meta http-equiv=refresh content='0;url=index.php'><? } else { echo "COULD NOT UPLOAD IMAGE <BR><BR>"; print_r($_FILES); } } else { echo "You did not chose an image to upload !"; //print_r($_FILES); // prints out $_FILES array content ?><meta http-equiv=refresh content='3;url=javascript:history.go(-1)'><? } } else // IF NOT INSERT OR ANYTHING ELSE, SHOW THE UPLOAD FORM { ?> <h2> Add e-Newsletter...</h2> <table cellpadding="3" cellspacing="0" border="0" style="border: 1px solid #CCCCCC; background-color: #EEEEEE;" width="20%"> <tr> <form action="admin_newsletters.php" method="post" enctype="multipart/form-data"> <td align="center"> <input type="file" name="image" id="image" /><br /> <input type="hidden" name="action" value="insert" /> <input type="submit" value="Upload eNewsletter" /> </td> </form> </tr> </table> <? } ?> the print_r($_files) returns Array ( [image] => Array ( [name] => 100407_HANDTRK.jpg [type] => image/pjpeg [tmp_name] => /tmp/phpQSgJEn [error] => 0 => 60190 ) ) Thanks 2 All ! Quote Link to comment https://forums.phpfreaks.com/topic/71817-solved-im-losing-it-whats-going-on-here/ Share on other sites More sharing options...
trq Posted October 4, 2007 Share Posted October 4, 2007 Have you made any attempts to produce an error? Quote Link to comment https://forums.phpfreaks.com/topic/71817-solved-im-losing-it-whats-going-on-here/#findComment-361701 Share on other sites More sharing options...
iPixel Posted October 4, 2007 Author Share Posted October 4, 2007 Im not sure i follow.. "produce and error?" Quote Link to comment https://forums.phpfreaks.com/topic/71817-solved-im-losing-it-whats-going-on-here/#findComment-361702 Share on other sites More sharing options...
trq Posted October 4, 2007 Share Posted October 4, 2007 Have you turned on error reporting so you can actually see what error is produced (if any)? Quote Link to comment https://forums.phpfreaks.com/topic/71817-solved-im-losing-it-whats-going-on-here/#findComment-361703 Share on other sites More sharing options...
iPixel Posted October 4, 2007 Author Share Posted October 4, 2007 I know im being noobish about it but how might i do that ? in my info.php file my error_reporting is 6135 if that means anything. error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/71817-solved-im-losing-it-whats-going-on-here/#findComment-361705 Share on other sites More sharing options...
iPixel Posted October 4, 2007 Author Share Posted October 4, 2007 Here's the error from my cPanel Error Log... [error] PHP Warning: move_uploaded_file(upload/newsletters/100407_HANDTRK.jpg) [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: failed to open stream: No such file or directory in /home/globinfo/public_html/admin/admin_newsletters.php on line 30 i've heard of this failed to open stream: error before but no clue how to fix it yet. EDIT ===== GOT IT WORKIN TY ALL Quote Link to comment https://forums.phpfreaks.com/topic/71817-solved-im-losing-it-whats-going-on-here/#findComment-361728 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.