/    Sign up×
Community /Pin to ProfileBookmark

upload works but jpgs are corrupted??

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.

[CODE]
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”);

}
}
}
[/CODE]

thanks!

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@launchpad67aMay 24.2007 — 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.
Copy linkTweet thisAlerts:
@kreddauthorMay 24.2007 — 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?

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



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
Copy linkTweet thisAlerts:
@kreddauthorMay 25.2007 — anyone?? anyone??

when i do this:

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


i get this:

[CODE]
image/pjpeg
[/CODE]



/////

EDITED AFTER I DID THIS:

[CODE]
echo filetype($type_file);

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


why can i ftp all my jpgs just fine but php doesn't like them??
Copy linkTweet thisAlerts:
@NogDogMay 26.2007 — You should probably be using [url=http://www.php.net/move_uploaded_file]move_uploaded_file[/url]() instead of copy().
Copy linkTweet thisAlerts:
@kreddauthorMay 26.2007 — 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.
×

Success!

Help @kredd spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...