I thought I had this figured out, and I'm sure it's probably something very simple to someone who has been doing this for a while, but I'm just not experienced enough with PHP to get it to work. If anyone can tell me what the issue is with this code, I'd sure appreciate it.
if(isset($_POST['s1']))
{
if(!empty($_FILES['images']['name'][0]))
{
while(list($key,$value) = each($_FILES['images']['name']))
{
if(!empty($value))
{
$NewImageName = $t."_".$value;
copy($_FILES['images']['tmp_name'][$key], "re_images/".$NewImageName);
$MyImages[] = $NewImageName;
}
}
if(!empty($MyImages))
{
$ImageStr = implode("|", $MyImages);
$Thumbnail = "thumb_".$MyImages[0];
$tc = $MyImages[0];
$filename = $_FILES['images']['name'][0];
$temporary_name = $_FILES['images']['tmp_name'][0];
$mimetype = $_FILES['images]']['type'][0];
$filesize = $_FILES['images']['size'][0];
switch($mimetype)
{
case "image/jpg" :
case "image/jpeg" :
case "image/pjpeg" :
$i = imagecreatefromjpeg($temporary_name);
break;
case "image/gif" :
$i = imagecreatefromgif($temporary_name);
break;
case "image/png" :
$i = imagecreatefrompng($temporary_name);
break;
}
var_dump ($_FILES ); echo ( "<br>\n");
echo ("print " . $i . "<br>\n");
echo ("temp_name " . $temporary_name);
unlink($temporary_name);
$dest_x = 80;
$dest_y = 60;
/* LINE 52 */ if(imagesx($i) > $dest_x || imagesy($i) > $dest_y)
{
if(imagesx($i) >= imagesy($i))
{
$thumb_x = $dest_x;
$thumb_y = imagesy($i) * ($dest_x / imagesx($i));
}
else
{
$thumb_x = imagesx($i) * ( $dest_y / imagesy($i));
$thumb_y = $dest_y;
}
}
else
{
$dest_x = imagesx($i);
$dest_y = imagesy($i);
}
imagecreatetruecolor($thumb_x, $thumb_y);
imagecopyresampled($thumb, $i, 0, 0, 0, 0, $thumb_x, $thumb_y, imagesx($i), imagesy($i));
imagejpeg($thumb, "thumbs/".$Thumbnail, 80);
}
}
The following errors are what I'm getting:
string(10) "Array"
print
temp_name /Applications/MAMP/tmp/php/phpOKgqTF
Warning: imagesx(): supplied argument is not a valid Image resource in /Applications/MAMP/htdocs/AddOffer.php on line 52
Warning: imagesy(): supplied argument is not a valid Image resource in /Applications/MAMP/htdocs/AddOffer.php on line 52
Warning: imagesx(): supplied argument is not a valid Image resource in /Applications/MAMP/htdocs/AddOffer.php on line 67
Warning: imagesy(): supplied argument is not a valid Image resource in /Applications/MAMP/htdocs/AddOffer.php on line 68
Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /Applications/MAMP/htdocs/AddOffer.php on line 70
Warning: imagesx(): supplied argument is not a valid Image resource in /Applications/MAMP/htdocs/AddOffer.php on line 71
Warning: imagesy(): supplied argument is not a valid Image resource in /Applications/MAMP/htdocs/AddOffer.php on line 71
Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /Applications/MAMP/htdocs/AddOffer.php on line 71
Warning: imagejpeg(): supplied argument is not a valid Image resource in /Applications/MAMP/htdocs/AddOffer.php on line 72