【发布时间】:2015-04-15 17:08:54
【问题描述】:
您好,我正在尝试使用 php 将我制作的网站上的照片上传到网站托管服务器的文件夹目录 (/public_html/upload/)。但该文件夹总是显示为空。我不知道我做错了什么。谁能帮忙?
这是 html 文件:
<div id = "forms">
<form action="add_data.php" method="post" form enctype="multipart/form-data">
<div id = "info1">
<p> <h2> Accident Report Form </h2> </p>
</div>
<div id = "info2"><p> Please fill in the form below to report an accident </p></div>
<ol>
<li> <label for = "name" > Name: </label>
<input "type = "text" name = "name" id = "name"/> </li>
<li> <label for = "location" > Location of the accident: </label>
<input "type = "text" name = "location" id = "location" /> </li>
<li> <label for = "road" > Road Name: </label>
<input "type = "text" name = "road" id = "road"/> </li>
<li> <label for = "image" > Image: </label>
<input type="file" name="photo"><br> </li>
</ol>
<div id = "submit"><button type="submit" >Submit</button> </div><br>
</form>
</div>
而且,这是 add_data.php 文件:
<?php
$target = "/public_html/upload";
$target = $target . basename( $_FILES['photo']['name']);
$pic=($_FILES['photo']['name']);
?>
【问题讨论】:
-
也许你可以阅读php文件上传文档php.net/manual/en/features.file-upload.post-method.php ...
标签: php jquery html file-upload image-uploading