如何从xampp读取上传的文件

发布于 2024-09-01 11:10:32 字数 927 浏览 5 评论 0原文

我有这个用于在服务器上上传文件的代码:

<tr>
<td>
<form enctype="multipart/form-data" action="uploadaction.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
</td>
</tr>
<tr>
<td>
Select the image: <input name="uploadedfile" type="file" />

</td>
<tr>
<td>
<input type="submit" value="Upload File" />
</form>
</td>
</tr>

这是操作表单:

<?php
$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}
?>

我将使用什么 php 函数? 您能给我一个如何读回文件并将其显示在浏览器中的示例吗? 请帮忙,谢谢。

I have this code for uploading files on the server:

<tr>
<td>
<form enctype="multipart/form-data" action="uploadaction.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
</td>
</tr>
<tr>
<td>
Select the image: <input name="uploadedfile" type="file" />

</td>
<tr>
<td>
<input type="submit" value="Upload File" />
</form>
</td>
</tr>

And here's the action form:

<?php
$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}
?>

What php function will I use?
Can you give me an example on how to read the file back and display it in the browser?
Please help, thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不回头走下去 2024-09-08 11:10:32

PHP 有关文件上传的文档 应该可以解决您的问题。如果没有,并且您仍然有疑问,请随时回来再次询问。

PHP's documentation about file uploads should solve your problem. If it does not and you still have a question about it, feel free to come back and ask again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文