zimmo Posted September 18, 2009 Share Posted September 18, 2009 Due to the changes we have made with the system, we need to change the following that was not written by me. I have a script which I enclose a portion of it here, but it needs to check now if the database has A or B or YOUCHOOSE in the table and then upload an image if it does. Basically at the moment, when you upload an image it is failing to upload and redirecting to the page. // pic name will be user's ID + month $pic_name ='/uploads/'.(int)$_REQUEST['id'].'/'.(int)$_REQUEST['id'].'frontcover'.'.jpg'; $exists = false; if (isset($_FILES['frontcoverpic']) && $_FILES['frontcoverpic']['size'] > 0) { // see if image for this month has already been uploaded $res = mysql_query('select 1 from uploadcentre where frontcoverpic ="'.$pic_name.'" and email = "'.$_REQUEST['email'].'" and id ='.(int)$_REQUEST['id']); $exists = ($res && mysql_num_rows($res) > 0); // check image type is ok $img_info = getimagesize($_FILES['frontcoverpic']['tmp_name']); if ($img_info[2] != 2) { // not jpeg header("Location: http://www.*****.co.uk/*****/calendar/error.php?email={$_REQUEST['email']}&name={$_REQUEST['name']}&id={$_REQUEST['id']}"); exit(); } // ok image -- re-upload will overwrite previous item if (!move_uploaded_file($_FILES['frontcoverpic']['tmp_name'],$pic_name)) { die('could not install new image'); } I think the problem lies where it checks to see if the image has been uploaded, when in fact it could just contain data in that field of A or B or YOUCHOOSE. Link to comment https://forums.phpfreaks.com/topic/174697-extending-my-script/ Share on other sites More sharing options...
zimmo Posted September 18, 2009 Author Share Posted September 18, 2009 the database is updated also via another script which just inserts the A or B into the field in mysql. But because it does this, if the user tries to upload a picture it does not let them as it thinks its there already. Link to comment https://forums.phpfreaks.com/topic/174697-extending-my-script/#findComment-920715 Share on other sites More sharing options...
zimmo Posted September 18, 2009 Author Share Posted September 18, 2009 Sorry to bug people with this one, just need it sorting asap. What its doing is not uploading as it see something in the database, in the database with be either 3 things, the letter A or the letter B or YOUCHOOSE!! help!!!! Link to comment https://forums.phpfreaks.com/topic/174697-extending-my-script/#findComment-920744 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.