Jump to content

upload jpg with ftp -fine, upload with php wrong file type!


Recommended Posts

hello everyone, i've scripted a file uploader, about as basic as you can get, and works on all accounts except that it tells me every single jpg is the wrong file type - BUT i can ftp all these same images and they all behave correctly.

 

echo filetype($type_file);

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

 

any ideas? thanks!

That means it can't determine what type the file is, not that it's the wrong type.

 

ruach at chpc dot utah dot edu

10-Mar-2004 05:11

There are 7 values that can be returned. Here is a list of them and what each one means

 

block: block special device

 

char: character special device

 

dir: directory

 

fifo: FIFO (named pipe)

 

file: regular file

 

link: symbolic link

 

unknown: unknown file type

well ok, thanks for the clarification. but why can't it tell? i've searched and searched AND searched some more looking for info or code to fix it. i can't imagine it being the fault of the jpg itself, not ruling it out ;) but i've yet to find any code used in any uploading examples that require or use some sort of specification of the file type. they all just select the file, destination and move it. i'm pulling my hair trying to figure out what i've missed.

are you using a relative path or an absolute path to the file?  I've experienced problems using any of the "stat" related functions with relative paths before.

 

The simplest thing to do would be to check the file extension when it's uploaded and make sure it is of the type that you want to keep.

well, now i've tried both abs and rel paths and no dice. i can echo all the vars and i can see the file extension is jpg. if i take out the if (filetype == "image/pjpg") the jpgs are uploaded to the server fine...they say 'filename.jpg' but the browser won't recognize them as jpgs when i try to view them in my gallery or even directly in a browser.

 

 

$extension = pathinfo($_FILES['imagefile']['name']);
$extension = $extension[extension];

 

this returns 'jpg'. soit should know that they are in fact jpgs, correct?  i'm thoroughly confused  ???

This is going to sound nuts and if there is an experienced PHP coder out there..you have permission to laugh. I had this problem once before. I cant remember what I did exactly but I think I remember it had something to do ith the extension.

 

try changing your extension to JPG jpg jpeg JPEG.

I also remember that somehow photoshop got involved. The camera that took the pictures that I was trying to uplaod named the files DCM_xxxx.JPEG I think I had to use photoshop and resave the pictures as a photoshop generated file dcm_xx.jpg.

 

Thats it. Laugh

thanks for the suggestion but this uploader isn't for me so i need a solution that will allow the end user to not have to worry about how they save their files, you know?

 

could this all be a server problem? i checked the php services with phpinfo() and it says everything is running, exif, jpeg/tiff support, the gd2 library, but i get errors on everything. i checked out the .ini file in my remote directory and there is barely anything in it...is there a relationship b/n the info spit out using phpinfo() and what's in my .ini file?

 

also the phpinfo() says my ext dir is './' shouldn't it be './ext' in php5?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.