【问题标题】:Image losing quality after upload to FTP server using PHP使用 PHP 上传到 FTP 服务器后图像质量丢失
【发布时间】:2016-08-10 15:01:42
【问题描述】:

我编写了一个脚本来将图像上传到 FTP 服务器,但图像质量下降 - 似乎只有 256 像素

我的 HTML:

<form action="upload_image_travel.php" enctype="multipart/form-data" method="post">
    <input name="file" type="file" accept="image/jpeg"/>Upload foto in folderul travel/imagini/ pentru ARTICOL
    <input name="submit" type="submit" value="Upload File in TRAVEL" />
    </form>

还有我的upload.php:

$ftp_server = "xxxxx";
$ftp_user_name = "xxxxx";
$ftp_user_pass = "xxxxx";
$destination_file = "/public_html/travel/imagini/" . $_FILES['file']['name'];
$source_file = $_FILES['file']['tmp_name'];

// set up basic connection
$conn_id = ftp_connect($ftp_server);
ftp_pasv($conn_id, true); 

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); 

// check connection
if ((!$conn_id) || (!$login_result)) { 
    echo "FTP connection has failed!";
    echo "Attempted to connect to $ftp_server for user $ftp_user_name"; 
    exit; 
} else {
    echo "Connected to $ftp_server, for user $ftp_user_name";
}

// upload the file
if (ftp_put($conn_id, $destination_file, $source_file, FTP_ASCII)) {
   echo "successfully uploaded $destination_file\n";
   header('Location: administrator/admin_index_travel.php');
} else {
   echo "There was a problem while uploading $destination_file\n";
}

// close the FTP stream 
ftp_close($conn_id);

【问题讨论】:

  • 尝试FTP_BINARY 而不是FTP_ASCII
  • 上传前客户端有多少像素?
  • 我改成FTP_BINARY,现在可以工作了……谢谢人

标签: php ftp image-uploading


【解决方案1】:

也许应该是 FTP_BINARY?不是ASCII?

【讨论】:

  • 你在写...是这个声明中的问题...谢谢
猜你喜欢
  • 2013-02-17
  • 2018-09-27
  • 2016-01-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-29
  • 2017-07-26
  • 2019-09-14
相关资源
最近更新 更多