ccbayer Posted February 24, 2010 Share Posted February 24, 2010 Hey - I'm building a web-based FTP client for users to put and get files to and from their directory. Everything is working fine - I can upload, download, traverse the FTP folders, etc - except when i download a file that I have uploaded using my tool. text files work ok, but image files are unopenable by photoshop, etc. I am running this locally, for what its worth. Here's how i'm transferring the file from the web server to the FTP server: $filename = basename($_FILES['uploadedfile']['name']); $uploadlocation = 'uploads/'.$filename; if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $uploadlocation)) { //FTP file to correct directory if (@ftp_login($conn_id, $_SESSION['ftp_username'], $_SESSION['ftp_pass'])) { $fp = fopen($uploadlocation,'r') or die('could not open stream'); if(ftp_fput($conn_id,$dir."/".$filename, $fp, FTP_ASCII)){ echo 'Your file has been uploaded!'; }else{ echo 'problem moving file from local to ftp'; } } }else{ echo 'problem moving uploaded file'; } Now, somewhere in this step is where the breakdown happens, i believe. I tested this by downloading the file on the webserver (from the upload directory), and it works just fine. When i get the on from the FTP server (either using my web-client OR filezilla) and try to open in photoshop, it gives me an error that reads: "Could not complete your request because an invalid DQT JPEG segment QTable number is found (it must be <4)." while i have no idea what THAT means, i can only assume that transferring from my webserver to my ftp server changed the file .... somehow. Is this a binary vs. ascii thing? something else? any clues? Link to comment https://forums.phpfreaks.com/topic/193274-ftp_fputs-changing-mime-type-or-something-of-image-file/ Share on other sites More sharing options...
ccbayer Posted February 24, 2010 Author Share Posted February 24, 2010 duh, i think i answered my own question. i'll just detect the mime type when i upload and change from ASCII to binary based on that. Link to comment https://forums.phpfreaks.com/topic/193274-ftp_fputs-changing-mime-type-or-something-of-image-file/#findComment-1017701 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.