[英]PHP - Upload images to FTP directory and then Display images uploaded only from directory
[英]PHP - Upload images to FTP directory and then Display images uploaded only from directory - 2
嘗試上傳並顯示圖像時,出現“無法移動上傳的文件”。 不知道我要去哪里錯了..
這是我的image.php:
<form enctype="multipart/form-data" action="upload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile_1" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
這是我的upload.php:
<?php
$ftp_server = "localhost";
$ftp_username = "xxx";
$ftp_password = "xxx";
$conn_id = ftp_connect($ftp_server) or die("could not connect to $ftp_server");
if(@ftp_login($conn_id, $ftp_username, $ftp_password))
{
echo "connected as $ftp_username@$ftp_server\n";
}
else {
echo "could not connect as $ftp_username\n";
}
$remote_file_path = "/2013/img/" . $_FILES['uploadedfile_1']['name'];
if ( $_FILES['uploadedfile_1']['error'] )
die( "Upload failed with error code " . $_FILES['uploadedfile_1']['error'] );
$new_path = '/2013/img/tmp/' . $_FILES['uploadedfile_1']['name'];
if ( ! move_uploaded_file( $_FILES['uploadedfile_1']['tmp_name'], $new_path ) ) {
die( "Failed moving the uploaded file" );
}
ftp_put($conn_id, $remote_file_path, $new_path,FTP_BINARY);
echo "<img src='$new_path' alt='Your uploaded file' />";
?>
任何幫助將非常感激。
您嘗試放置圖像的文件夾存在問題
試試這個看看是否可行
if ( ! move_uploaded_file( $_FILES['uploadedfile_1']['tmp_name'], 'D:/'.$_FILES['uploadedfile_1']['name']
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.