I have a peice of code (I'm working on) that uploads form data, including an image file, resizes that image, and saves a smaller copy of that image is another directory. It works , except I get this distracting error.
[BR]How do I get rid of this error ? ( I have "x'd " out website info)
I appreciate any help I can get.....
Here is the error:
Warning: copy(/tmp/phpHyMm1N) [function.copy]: failed to open stream: No such file or directory in /home/thrsevfi/public_html/IA/odr/AutoTrader.php on line 94[BR]
Here is the script/code
<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','DateRcvd');
pt_register('POST','status');
pt_register('POST','mgrName');
pt_register('POST','ItemDescr2');
pt_register('POST','ItemDescr');
pt_register('POST','Kcondition');
pt_register('POST','Kcomments');
pt_register('POST','Property');
pt_register('POST','Lot');
pt_register('POST','Value');
pt_register('POST','FMValue');
pt_register('POST','Quantity');
pt_register('POST','Fund');
pt_register('POST','Activity');
pt_register('POST','CostCtr');
pt_register('POST','Spare');
pt_register('POST','ID');
$Photo=$HTTP_POST_FILES['Photo'];
if($HTTP_POST_FILES['Photo']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['Photo']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['Photo']['name'].", was not uploaded!";
$errors=1;
}
$isset = $Photo;
$size = 80; // the thumbnail height
$filedir = 'autoimages/'; // the directory for the original image
$thumbdir = 'thumbs/'; // the directory for the thumbnail image
$prefix = 's'; // the prefix to be added to the original name
$maxfile = '2000000';
$mode = '0666';
$userfile_name = $_FILES['Photo']['name'];
$userfile_tmp = $_FILES['Photo']['tmp_name'];
$userfile_size = $_FILES['Photo']['size'];
$userfile_type = $_FILES['Photo']['type'];
//if (uploadedfile($_FILES['image']['name']))
if (isset($_FILES['Photo']['name']))
{
$prod_img = $filedir.$userfile_name;
$prod_img_thumb = $thumbdir.$prefix.$userfile_name;
move_uploaded_file($userfile_tmp, $prod_img);
chmod ($prod_img, octdec($mode));
$sizes = getimagesize($prod_img);
$aspect_ratio = $sizes[1]/$sizes[0];
if ($sizes[1] <= $size)
{
$new_width = $sizes[0];
$new_height = $sizes[1];
}else{
$new_height = $size;
$new_width = abs($new_height/$aspect_ratio);
}
$destimg=ImageCreateTrueColor($new_width,$new_height)
or die('Problem In Creating image');
$srcimg=ImageCreateFromJPEG($prod_img)
or die('Problem In opening Source Image');
if(function_exists('imagecopyresampled'))
{
imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg))
or die('Problem In resizing');
}else{
Imagecopyresized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg))
or die('Problem In resizing');
}
ImageJPEG($destimg,$prod_img_thumb,90)
or die('Problem In saving');
imagedestroy($destimg);
}
$DateRcvd = date("Y-m-d");
$ID = date("ymds");
$Lot = date("yd");
if($errors==1) echo $error;
else{
$image_part = "L"."".$HTTP_POST_FILES['Photo']['name'];
$image_list[12] = $image_part;
copy($HTTP_POST_FILES['Photo']['tmp_name'], "autoimages/" );
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="DateRcvd: ".$DateRcvd."
mgrName: ".$mgrName."
ItemDescr: ".$ItemDescr."
Kcondition: ".$Kcondition."
Kcomments: ".$Kcomments."
Property: ".$Property."
Value: ".$Value."
FMValue: ".$FMValue."
Quantity: ".$Quantity."
Fund: ".$Fund."
Activity: ".$Activity."
CostCtr: ".$CostCtr."
Photo: ".$where_form_is."www.xxxxxxxx.com/IA/NEISO/autoimages/".$image_list[12]."
ID: ".$ID."
";
$message2= "Items requested for approval to sell at NAF Resale Store, click here for a Listing [url]http://www.xxxxxxx.com/cgi-bin/NEISA.pl?status=Hold[/url]
";
$message2 = stripslashes($message2);
$message = stripslashes($message);
mail("xxxxxxx.xxxxxx@xxxxxxxx.af.mil","Request to Approve NAF Resale Items",$message2,"From: WebSite");
mail("xxxxxxxxxxxx.xxxx@xxxxxxx.af.mil","(Copy)Request to Approve NAF Resale Items",$message,"From: WebSite");
$make=fopen("NEISOdata.dat","a");
$to_put="";
$to_put .= "|".$DateRcvd."|".$status."|".$mgrName."|".$ItemDescr."|".$ItemDescr2."|".$Kcondition."|".$Kcomments."|".$Property."|".$Lot."|".$Value."|".$FMValue."|".$Quantity."|".$Fund."|".$Activity."|".$CostCtr."|".$image_list[12]."|".$ID."|".$Spare."|
";
fwrite($make,$to_put);
?>
<h2>Thank you!</h2>
To add additional items from same cost center,
<INPUT TYPE=BUTTON ONCLICK='history.back()' VALUE=' Return to the previous page '> and change the appropriate info , then click Add Item.
<?php
}
?>