Jump to content

Extending my script


zimmo

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.