文件上传在引导程序中不起作用

时间:2015-06-01 19:01:05

标签: twitter-bootstrap

我正在尝试附加一个文件,但它不能与bootstrap一起工作。 有什么问题?

<form action="uploadfile.jsp" method="post"
                        enctype="multipart/form-data">
<input type="file"  name="file"  />
<br />
<input type="submit" value="Upload File" />

1 个答案:

答案 0 :(得分:1)

你有什么可以移动文件吗?我想不是。你的表格写得很好,方法是正确的,也是enctype。但要将它们移动到目标文件,您必须使用move_uploaded_file

$target_dir = "uploads/";//this is the url of the directory where 
                        //you want to store the uploaded files
if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)) {
   //file successfully uploaded 
}else{
  //there was an error uploading the file....
}