Jump to content

[SOLVED] I dont know What Problem this is...


midwestkel

Recommended Posts

Ok, I took over a site that someone else did and they have a script that uploads and pic to a page and 0changes the link that page goes to. My problem is that the pic doesnt upload but the link changes, I get an error saying this "UpdatedProblem In saving."

 

Here is the code for the page that is doing its thing does anyone have any ideas what is wrong? Thanks

<?

$id="featuredevent";
$featuredURL = $_POST['featured_url'];

include("dbinfo.inc.php");
mysql_connect($host,$username,$password);

$featuredURLquery="UPDATE `frontpage` SET `link` = '$featuredURL' WHERE `title` = 'featuredevent' LIMIT 1";
@mysql_select_db($database) or die( "Unable to select database");
mysql_query($featuredURLquery);
echo "$featuredURL Updated";
mysql_close();


if(isset($_POST['submit2']))
{
// the thumbnail width
$size = 350;

// the directory where the original uploaded image is saved
$filedir = "../images/";
// the directory where the thumbnail image is saved
$thumbdir = "../images/";
// the prefix to be added to the original name to name the thumbnail
$prefix = "$title";

// the file settings for the uploaded image
$mode = '0666';

$userfile_name = $_FILES['image']['name'];
$userfile_tmp = $_FILES['image']['tmp_name'];
$userfile_size = $_FILES['image']['size'];
$userfile_type = $_FILES['image']['type'];

$dummy = explode("." , $userfile_name);
$userfile_ext = $dummy[count($dummy) - 1]; 


if(isset($_FILES['image']['name'])) 
{
	//$prod_img = $filedir.$userfile_name;
	$prod_img = $filedir.$id.".".$userfile_ext; 

	//$prod_img_thumb = $thumbdir.$prefix.$userfile_name;
	$prod_img_thumb = $thumbdir.$prefix.$id.".".$userfile_ext; 
	move_uploaded_file($userfile_tmp, $prod_img);
	chmod($prod_img, octdec($mode));

	$sizes = getimagesize($prod_img);
	$aspect_ratio = $sizes[0]/$sizes[1];
	if ($sizes[1] <= $size)
	{
	$new_w= $sizes[1];
	$new_h = $sizes[0];
	}else{
	$new_w = $size;
	$new_h = abs($new_w/$aspect_ratio); 
}

	$destimg=imagecreatetruecolor($new_w,$new_h)
		or die('Problem In Creating image');
	$srcimg=imagecreatefromjpeg($prod_img)
		or die('Problem In opening Source Image');
	imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_w,$new_h,imagesx($srcimg),imagesy($srcimg))
		or die('Problem In resizing');
	imagejpeg($destimg,$prod_img_thumb,90)
		or die('Problem In saving');
	imagedestroy($destimg);
}
}
echo "This image, $prod_img,  ";
echo "was succesfully uploaded.";
echo "<img src='../images/featuredevent.jpg'>";

?>

Link to comment
Share on other sites

Make sure you've got write permissions in the directory (try writing a text file), other than that it basically looks ok.

 

Print out the $_FILES[][error]

e.g.

UPLOAD_ERR_OK

    Value: 0; There is no error, the file uploaded with success.

UPLOAD_ERR_INI_SIZE

    Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.

UPLOAD_ERR_FORM_SIZE

    Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.

UPLOAD_ERR_PARTIAL

    Value: 3; The uploaded file was only partially uploaded.

UPLOAD_ERR_NO_FILE

    Value: 4; No file was uploaded.

UPLOAD_ERR_NO_TMP_DIR

    Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.

UPLOAD_ERR_CANT_WRITE

    Value: 7; Failed to write file to disk. Introduced in PHP 5.1.0.

UPLOAD_ERR_EXTENSION

    Value: 8; File upload stopped by extension. Introduced in PHP 5.2.0.

 

http://uk.php.net/manual/en/features.file-upload.php

http://uk.php.net/manual/en/features.file-upload.errors.php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.