Hello...
I have an upload script that I found online (I've only worked with uploads once in my life, and it didn't involve image resizing):
The error comes on the line with the unlink($tmpimg) function at the end of the resizing where it deletes the temporary file. It says there's no such file or directory, yet there's no other errors given out.
Any help appreciated
Thanks.
.chulium.
(I didn't include *ALL* of the code, like the form, etc, but everything else is working fine. I've spent hours trying to debug this script... trust me on the previous code: it's good.)
I have an upload script that I found online (I've only worked with uploads once in my life, and it didn't involve image resizing):
PHP:
/*== only resize if the image is larger than 660 x 1000 ==*/
$imgsize = GetImageSize($imgfile);
/*== check size 0=width, 1=height ==*/
if (($imgsize[0] > 660) || ($imgsize[1] > 1000))
{
/*== temp image file -- use "tempnam()" to generate the temp
file name. This is done so if multiple people access the
script at once they won't ruin each other's temp file ==*/
$tmpimg = tempnam("/tmp", "MKUP");
/*== RESIZE PROCESS
1. decompress jpeg image to pnm file (a raw image type)
2. scale pnm image
3. compress pnm file to jpeg image
==*/
/*== Step 1: djpeg decompresses jpeg to pnm ==*/
system("djpeg $imgfile >$tmpimg");
/*== Steps 2&3: scale image using pnmscale and then
pipe into cjpeg to output jpeg file ==*/
system("pnmscale -xy 660 1000 $tmpimg | cjpeg -smoo 10 -qual 50 >$imgfile");
/*== remove temp image ==*/
unlink($tmpimg);
}
/*== setup final file location and name ==*/
/*== change spaces to underscores in filename ==*/
$final_filename = str_replace(" ", "_", $imgfile_name);
$newfile = $uploaddir . "/$final_filename";
/*== delete the temporary uploaded file ==*/
unlink($imgfile);
//print("<img src=\"$final_filename\">");
/*== do extra security check to prevent malicious abuse==*/
if (is_uploaded_file($imgfile))
{
/*== move file to proper directory ==*/
if (!copy($imgfile,"$newfile"))
{
/*== if an error occurs the file could not
be written, read or possibly does not exist ==*/
print "Error Uploading File.";
exit();
}
}
The error comes on the line with the unlink($tmpimg) function at the end of the resizing where it deletes the temporary file. It says there's no such file or directory, yet there's no other errors given out.
Any help appreciated
.chulium.
(I didn't include *ALL* of the code, like the form, etc, but everything else is working fine. I've spent hours trying to debug this script... trust me on the previous code: it's good.)








