【发布时间】:2011-05-22 01:27:38
【问题描述】:
我想用 PHP 上传文件,我使用 move_uplload_files 将它们复制到我想要的目标文件夹,一切正常:
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], './uploades/'))
die("success");
else
die("error");
但是当我尝试这个时
$rand = chr(rand(97, 122)). chr(rand(97, 122)). chr(rand(97, 122));
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], './uploades/'.$rand))
die("success");
else
die("error");
我会收到错误,看起来 move_uploaded_files 无法创建文件夹。我该怎么做?
基本上我正在寻找一种方法来做到这一点,例如 file_put_contents(),如果不存在则创建路径。
【问题讨论】:
标签: php file-upload upload