繁体   English   中英

文件上传不适用于PHP

[英]File upload Not Working with PHP

因此,我有一个允许用户上传文件的表单。 当他们提交文件时,我可以获取文件信息,例如nametmp_name ,但实际上传不起作用。 我也没有任何PHP错误。 下面是我的代码,我想我只需要再看一眼,就像几天前一样。

//Get the file name
$target_Dir = "temp/";

$tempName = $_FILES['file']['tmp_name'];

$target_file = $target_Dir . basename($_FILES["file"]["name"]);

$filename = pathinfo($target_file, PATHINFO_FILENAME);

//Get the password
$password = $_POST['password'];
//Store if the user wants the certificate to remain password protected
$passProtect = $_POST['passProtect'];
//upload the file to the server
move_uploaded_file($tempName, $target_file);

如果您想知道为什么我要存储不带扩展名的文件名,则在代码中稍后需要使用不带扩展名的文件名。

我想你只是犯了这个错误

$fileExtension = pathinfo($target_file, PATHINFO_FILENAME);

尝试使用该代码的此插入内容,那么只有您将获得文件名而不是扩展名。

由于不记得的原因,我的脚本中还有一个unlink() 它删除了用户立即上传的文件。

感谢您提供的额外的支持。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM