尝试上传多个文件 Move_uploaded_file不起作用。 文件权限用户#777
$file = $_FILES['photo'];
$count = count($file['name']);
for($a = 0 ; $a<$count ; $a++)
{
echo $_FILES['photo']['name'][$a];
$target_dir = preg_replace('/\s+/',
'',$name.'_'.basename($_FILES['photo']['name'][$a]));
$target_file = "../upload/".$target_dir;
echo $target_file;
if(move_uploaded_file($_FILES['photo']["name"][$a], $target_file))
{
echo 'yes';
}
else
{
echo 'no';
}
}
答案 0 :(得分:0)
你可能指着错误的道路。使用$ _SERVER ['DOCUMENT_ROOT']完成它。
:此:强>
$target_file = "../upload/".$target_dir;
以强>
$target_file = $_SERVER['DOCUMENT_ROOT']."/upload/".$target_dir;
源文件应为'tmp_name',而不是'name'。
发件人:强>
if(move_uploaded_file($_FILES['photo']["name"][$a], $target_file)){
要强>
if(move_uploaded_file($_FILES['photo']["tmp_name"][$a], $target_file)){
如果上述更改仍无法修复:
检查您的php.ini
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
; Whether to allow HTTP file uploads.
file_uploads = On
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;upload_tmp_dir =
; Maximum allowed size for uploaded files.
upload_max_filesize = 50M
; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20