我只是希望在我使用表单文件上传上传图像后,它将在下一页显示这些图像。图像被上传到 ftp 上的文件夹。我到处找,但似乎找不到正确的解决方案。
这是上传图片 (image.php) 的 HTML 代码:
<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 />
Choose a file to upload: <input name="uploadedfile_2" type="file" /><br />
<input type="submit" value="Upload Files" />
</form>
这是下一页上的 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";
}
$file = $_FILES["uploadedfile_1"]["name"];
$file2 = $_FILES["uploadedfile_2"]["name"];
$remote_file_path = "/2013/img/".$file;
$remote_file_path2 = "/2013/img/".$file2;
ftp_put($conn_id, $remote_file_path, $_FILES["uploadedfile_1"]["tmp_name"],FTP_ASCII);
ftp_put($conn_id, $remote_file_path2, $_FILES["uploadedfile_2"]["tmp_name"],FTP_ASCII);
ftp_close($conn_id);
echo "\n\nconnection closed";
?>
以上只是上传代码,我不知道我需要使用什么 PHP 代码来显示图像,但通常,我想在 Upload.php 上回显这两个图像。这段代码有没有办法预测上传了哪些图像?
任何帮助将非常感激。