如何从xampp读取上传的文件
我有这个用于在服务器上上传文件的代码:
<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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.