Click to See Complete Forum and Search --> : upload works but jpgs are corrupted??


kredd
05-24-2007, 09:52 AM
not sure if corrupted is the right term, but my upload copies the file to a folder as well as copying a thumbnail version to a thumbnail folder. the upload works fine (well, as far as getting it on the server) and i can see the files on the server. but when i load them into my gallery i just get X's. their image properties in the browser show the correct file path to where they reside but the TYPE property is blank for both uploaded files - for some reason its not recognizing them as actual jpgs...

anyone ideas? here is a code snippet that does all the work.



if(isset( $_POST['Submit'] )) {

$badfile=$_FILES['imagefile']['name'];
$file=preg_replace('/ /','_',$badfile); // removes spaces
$filetype=substr($file,-4);
$upic = "../images/gallery/$dest_fldr/".$_FILES['imagefile']['name'];
$self = $_SERVER['PHP_SELF'];
$remove_ext = split('\.',$file);
$tmb_file = $remove_ext[0]."_tmb.jpg";

if (!file_exists($upic)) {

if($filetype==".jpg"){

copy ($_FILES['imagefile']['tmp_name'], "../images/gallery/$dest_fldr/".$_FILES['imagefile']['name']) or die ("Could not copy");
copy ($_FILES['imagefile']['tmp_name'], "../images/gallery/".$dest_fldr."_tmb/".$tmb_file) or die ("Could not copy");

}
}
}



thanks!

launchpad67a
05-24-2007, 10:32 AM
What type of gallery are you loading these into? Could you be uploading "progressive" jpg's instead of "baseline standard"?
What happens when you type the url to the image in your browser? Does the image appear? If so, then it is an issue with your gallery.

kredd
05-24-2007, 11:47 AM
it's just a photo gallery i created and no the images do not show up in a browser - but i can see them on the server so i know they exist(?). all images that are FTP'd to the site show up just fine - its the photos added using my upload page that are screwy...

should i be passing this info somewhere in the process of uploading?


$_FILES['imagefile']['type'];



also one correction, the image property TYPE isn't blank, it says "not available".

this was working two days ago but i don't see anything i could have added to my code to keep it from working. i can post my entire code if need be

kredd
05-25-2007, 05:35 PM
anyone?? anyone??

when i do this:


$file_type = $_FILES['imagefile']['type'];
echo $file_type;


i get this:


image/pjpeg



/////
EDITED AFTER I DID THIS:


echo filetype($type_file);

//got this warning
Warning: filetype() [function.filetype]: Lstat failed for image/pjpeg


why can i ftp all my jpgs just fine but php doesn't like them??

NogDog
05-25-2007, 08:06 PM
You should probably be using move_uploaded_file (http://www.php.net/move_uploaded_file)() instead of copy().

kredd
05-25-2007, 08:48 PM
well, i did in fact change that, but that doesn't really help the situation at hand since the filetype error doesn't allow the code to get that far b/c the move_uploaded__file() function only fires if the filetype is valid.