php upload image with ftp problem

Posted by ntan on Stack Overflow See other posts from Stack Overflow or by ntan
Published on 2010-04-29T09:32:36Z Indexed on 2010/04/29 9:47 UTC
Read the original article Hit count: 333

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about php

Related posts about ftp