Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-Fileuploads,[';tmp#u name';]不';t在物理上存在_Php_Html_Linux_File Upload - Fatal编程技术网

PHP-Fileuploads,[';tmp#u name';]不';t在物理上存在

PHP-Fileuploads,[';tmp#u name';]不';t在物理上存在,php,html,linux,file-upload,Php,Html,Linux,File Upload,这是一些非常基本的东西。 不知什么原因,我无法通过标准的HTML+PHP上传表单上传文件 该文件在本地/tmp下不存在 php.ini 上载代码(与html表单index.php位于同一文件中) 有关文件的权限和信息: 您是否已将post_max_size值设置为更高的值?自己解决了这个问题。 尽管这个问题很愚蠢,但答案更愚蠢 我假设该文件将在/tmp下存在足够长的时间,以使我能够见证它的创建,这一点从一开始就很愚蠢 但是尝试使用move\u上传的\u文件在尝试将其移动到/时返回false 原因

这是一些非常基本的东西。 不知什么原因,我无法通过标准的HTML+PHP上传表单上传文件

该文件在本地/tmp下不存在

php.ini 上载代码(与html表单index.php位于同一文件中) 有关文件的权限和信息:
您是否已将post_max_size值设置为更高的值?

自己解决了这个问题。 尽管这个问题很愚蠢,但答案更愚蠢

我假设该文件将在/tmp下存在足够长的时间,以使我能够见证它的创建,这一点从一开始就很愚蠢

但是尝试使用
move\u上传的\u文件
在尝试将其移动到
/
时返回
false
原因是文件夹的权限错误


移动上传的文件($src,/srv/http'+$src)只需将其移动到另一个临时位置即可工作(在修复了
/srv/http/tmp
上的写入权限后)

什么是
$files
。???变量名的大小写敏感度缺失$文件!==$_对我来说,这解决了调试输出问题。现在,我对这整件事的原始问题是,文件从未被创建(意思是,PHP或其他任何相关的东西)无法提取文件。操作是
/
,而不是upload.php。也许您只是将文件从
/tmp/
移动到
/home/torxed/
?当使用
移动上传的文件时,即使是大文件,这也很快,因为它只是更改文件的地址,而不是其内容。文件没有被复制,而是被移动了。如果你不使用上传的临时文件,它就消失了,这就是临时文件!这只解决了显示错误信息的调试输出问题。问题仍然是,我无法访问/tmp下的本地临时文件,因为它从一开始就没有创建过。我的错误,默认值(我将更新我的
php.ini
,是8M)我真的不知道,我投票指出我在php.ini剪切中遗漏了一个重要变量。即使没有解决这个问题,我还是错过了一个好机会。我正要告诉你,在创建文件的过程中,你将无法看到该文件。有时候,我不明白选民们,也不明白他们在没有适当解释的情况下这么做的原因。
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
; http://php.net/file-uploads
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; http://php.net/upload-tmp-dir
upload_tmp_dir = /tmp/

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 30M

; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20

; open_basedir, if set, limits all file operations to the defined directory
; and below.  This directive makes most sense if used in a per-directory
; or per-virtualhost web server configuration file. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
; http://php.net/open-basedir
open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/

; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
; http://php.net/post-max-size
post_max_size = 8M
print '<pre>';
print var_dump($_FILES);
print var_dump(is_uploaded_file($_FILES["file"]["tmp_name"]));
print is_writable('/tmp');
print '</pre>';
<form method="post" action="./" enctype="multipart/form-data">
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file"><br>
    <input type="submit" name="submit" value="Submit">
</form>
array(1) {
  ["file"]=>
  array(5) {
    ["name"]=>
    string(11) "test.jpg"
    ["type"]=>
    string(10) "image/jpeg"
    ["tmp_name"]=>
    string(14) "/tmp/php66JkW8"
    ["error"]=>
    int(0)
    ["size"]=>
    int(75766)
  }
}
bool(true)
1
[torxed@archie http]$ ls -l / | grep tmp
drwxrwxrwt   9 root root   220 Sep 26 13:34 tmp

[torxed@archie http]$ ls -lh /home/torxed/ | grep test
-rw-r--r--  1 torxed users  74K Sep 26 13:08 test.jpg
var_dump(is_uploaded_file($_FILES["file"]["tmp_name"]));
[torxed@archie http]$ ls -lh /srv/http | grep tmp
drwxr-xr-x 2 torxed root 4.0K Sep 26 14:10 tmp