0

在尝试上传图像并显示它时,我收到“移动上传的文件失败”。不知道我哪里错了。。

这是我的 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' />";
?>

任何帮助将非常感激。

4

1 回答 1

0

您尝试放置图像的文件夹有问题

试试这个看看它是否有效

if ( ! move_uploaded_file( $_FILES['uploadedfile_1']['tmp_name'], 'D:/'.$_FILES['uploadedfile_1']['name']

于 2013-11-05T22:55:20.930 回答