小编Ane*_*ele的帖子

如何使用PHP检索上传的文件

好.我在2011年8月24日以来在这个网站上搜索.(并不重要)一种显示用户上传文件的方法.我在管理员方面有我的表格,一切正常.我还有一个表格,显示用户填写的表格中的任何内容.但我无法在桌面上查看文件或其名称.

我的数据库表有一个主要标识auto_increment int(11)unsigned.

这是我写的代码:

//This gets all the other information from the form 
$company=$_POST['company']; 
$location=$_POST['location'];
$pic=($_FILES['userfile']['name']);

$query = "INSERT INTO user_DB VALUES ('','$company', '$location', '$userfile' )";

//target to the path of my files
$target_path = "uploads/post_id/";
if(!is_dir($target_path)) mkdir($target_path);
$uploadfile = $target_path . basename($_FILES['userfile']['name']);

//Move the uploaded file to $taget_path
(move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile));
Run Code Online (Sandbox Code Playgroud)

在您填写详细信息的表单上,我有以下内容:

<tr>
<td><label for="company_name">Company Name</label></td>
<td><input type="text" name="company" id="company" value="" size="38" /></td>
</tr>
<tr>
<td><label for="location">Location</label></td>
<td><input type="text" name="location" id="location" value="" /></td>
</tr>
<tr>
<td>Upload a File:</td>
<td><input name="userfile" …
Run Code Online (Sandbox Code Playgroud)

php mysql file-upload download

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

download ×1

file-upload ×1

mysql ×1

php ×1