[英]PHP - Upload images to FTP directory and then Display images uploaded only from directory - 2
While trying to upload image and display it, i'm getting the 'Failed moving the uploaded file'. 尝试上传并显示图像时,出现“无法移动上传的文件”。 Don't know where I'm going wrong..
不知道我要去哪里错了..
Here's my image.php: 这是我的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>
Here's my upload.php: 这是我的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' />";
?>
Any help would be much appreciated. 任何帮助将非常感激。
There is a problem with your folder where you try to put the image 您尝试放置图像的文件夹存在问题
try this see if it works 试试这个看看是否可行
if ( ! move_uploaded_file( $_FILES['uploadedfile_1']['tmp_name'], 'D:/'.$_FILES['uploadedfile_1']['name']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.