我使用下面的代碼通過FTPPHP上傳圖像
$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);
的FTP是創建該文件,並有大小,但該文件我得到上傳圖片不是image.When嘗試打開圖像查看器我得到錯誤。
開關之前到ftp我有這個代碼
$image=$database_row["image"];//image is store in database
$file = fopen("images/".$image_name, "w");
fwrite($file, $image);
fclose($file);
和工作正常,但現在我必須使用FTP。
我在想什麼。