【发布时间】: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