php upload image with ftp problem
- by ntan
Hi,
I am using the code below to upload an image through ftp
$sFile=$ftp_dir."/".$image_name;
$image=$database_row["image"];//image is store in database
$fh = tmpfile();
$fwrite($fh, $image);
$uploadFile = ftp_fput($conn_id, $sFile, $fh, FTP_ASCII);
fclose($fh);
The ftp is creating the file and has a size BUT the file i get is not an image.When try to open on image viewer i get error.
Before switch to ftp i had this code
$image=$database_row["image"];//image is store in database
$file = fopen( "images/".$image_name, "w" );
fwrite( $file, $image);
fclose( $file );
and was working fine, but now i have to use ftp.
What am i missing.