Jump to content

ftp_fputs changing MIME type - or something - of image file


ccbayer

Recommended Posts

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.