kredd Posted May 26, 2007 Share Posted May 26, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/53017-upload-jpg-with-ftp-fine-upload-with-php-wrong-file-type/ Share on other sites More sharing options...
hitman6003 Posted May 26, 2007 Share Posted May 26, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/53017-upload-jpg-with-ftp-fine-upload-with-php-wrong-file-type/#findComment-261932 Share on other sites More sharing options...
kredd Posted May 26, 2007 Author Share Posted May 26, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/53017-upload-jpg-with-ftp-fine-upload-with-php-wrong-file-type/#findComment-261936 Share on other sites More sharing options...
hitman6003 Posted May 26, 2007 Share Posted May 26, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/53017-upload-jpg-with-ftp-fine-upload-with-php-wrong-file-type/#findComment-261937 Share on other sites More sharing options...
kredd Posted May 26, 2007 Author Share Posted May 26, 2007 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 ??? Quote Link to comment https://forums.phpfreaks.com/topic/53017-upload-jpg-with-ftp-fine-upload-with-php-wrong-file-type/#findComment-261943 Share on other sites More sharing options...
elquijote Posted May 26, 2007 Share Posted May 26, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/53017-upload-jpg-with-ftp-fine-upload-with-php-wrong-file-type/#findComment-261970 Share on other sites More sharing options...
kredd Posted May 26, 2007 Author Share Posted May 26, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/53017-upload-jpg-with-ftp-fine-upload-with-php-wrong-file-type/#findComment-262129 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.