我制作了一个脚本,将图像上传到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);
答案 0 :(得分:-4)
也许它应该是FTP_BINARY?不是ascii?