如果我尝试上传图片...它会显示带有大小的根文件夹,但它只显示一个白色方块...不是具有分辨率的图片......
upload.php的
<?php require '../conx.php';
session_start();
if(isset($_SESSION["userID"])){
} else{
header('Location: ../login.php');
}
?>
<?php
$ftp_server = "ftp.xxxx.com";
$ftp_user_name = "xxxx@exemple.com";
$ftp_user_pass = "xxxxx";
$destination_file = "/public_html/lifestyle/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_lifestyle.php');
} else {
echo "There was a problem while uploading $destination_file\n";
}
// close the FTP stream
ftp_close($conn_id);
?>
形式
<form action="upload.php" enctype="multipart/form-data" method="post">
<input name="file" type="file" />
Upload foto in folderul lifestyle/imagini/ pentru ARTICOL
<input name="submit" type="submit" value="Upload File in lifestyle" />
</form>
如果我尝试使用绝对链接查看图片,它只显示白色方块...而不是图像。如果我使用FtpZilla上传图像,它的工作原理...... 所以我的表格一定有问题。
答案 0 :(得分:0)
一旦我遇到同样的问题。通过将此属性添加到<input type="file">
:
accept="image/jpeg"
如果您愿意,可以添加更多类型。希望有所帮助