在过go 的三天里,我一直在处理一个项目时遇到了一个问题,这个项目涉及到将文件和文本上传到我的服务器.每次用户上传内容时,都会在服务器上创建一个格式为YearMonthDay_HourMinuteSecond的新文件夹.

以前,在我的旧服务器上运行Ubuntu 22.04和Apache,代码运行得很好.然而,在更换服务器后,我面临着一个问题,我无法上传文件,但内容被上传了.我怀疑这个问题可能与文件夹和文件权限有关.

以下是目录和文件的权限:

apache 文件夹权限:

drwxr-xr-x root root 

上载页面和上载脚本的权限:

\-rw-r--r-- root root upload.html

\-rw-r--r-- root root upload.php

上载目录权限:

drwxrwxrwx www-data www-data  test_upload/

我认为这个问题可能与服务器上的权限有关.

上传.html:

<form action="upload.php" method="post" class="upload-form">
      <div class="file-input">
        <input class="pop" id="file" multiple name="file[]" type="file">
        <input class="tit" name="title" placeholder="Title" type="text">
        <textarea cols="50" name="story" placeholder="Story" rows="4"></textarea>
      </div>
</form>

active php.ini lines:

cat /etc/php/8.1/apache2/php.ini | grep -E "^[^;#]+"
[PHP]
engine = On
short_open_tag = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = -1
disable_functions =
disable_classes =
zend.enable_gc = On
zend.exception_ignore_args = On
zend.exception_string_param_max_len = 0
expose_php = Off
max_execution_time = 30
max_input_time = 60
memory_limit = 128M
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
log_errors = On
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 8M
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
default_charset = "UTF-8"
doc_root =
user_dir =
enable_dl = Off
file_uploads = On
upload_max_filesize = 2000M
max_file_uploads = 200000
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
extension=mysqli
[CLI Server]
cli_server.color = On
[Date]
[filter]
[iconv]
[imap]
[intl]
[sqlite3]
[Pcre]
[Pdo]
[Pdo_mysql]
pdo_mysql.default_socket=
[Phar]
[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = Off
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
[OCI8]
[PostgreSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[bcmath]
bcmath.scale = 0
[browscap]
[Session]
session.save_handler = files
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.cookie_samesite =
session.serialize_handler = php
session.gc_probability = 0
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.sid_length = 26
session.trans_sid_tags = "a=href,area=href,frame=src,form="
session.sid_bits_per_character = 5
[Assertion]
zend.assertions = -1
[COM]
[mbstring]
[gd]
[exif]
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
[sysvshm]
[ldap]
ldap.max_links = -1
[dba]
[opcache]
[curl]
[openssl]
[ffi]

any help with the problem pleas !

推荐答案

这么做

<form action="upload.php" method="post" class="upload-form" enctype="multipart/form-data">

Php相关问答推荐

为什么正则表达式与得到的文本块之前得到的也行?

WooCommerce常规价格增加额外的附加平价

PHP文件上载问题-";Move_Uploaded_Files";未按预期工作

如何在Laravel Model中自定义多个日期属性的日期格式?

将数据推入所有子数组条目

在WooCommerce购物车页面应用优惠券不会';t刷新总计

从 WooCommerce 购物车中删除总计部分,同时保留小计行

如何在laravel中获得两个时间戳之间的小时和分钟差异

多个产品类别 Select 自定义 WooCommerce 插件设置页面

过滤会员计划标题和标签

由于 PHP 版本不受支持,如何终止 PHP 脚本?

如何通过额外的属性和本地化来使用 laravel 枚举

PDO 和 SQL 查询结果中日期格式不同的原因可能是什么?

PHP Loop 在迭代中使用修改后的数据

如果 static:: 被解析为B,为什么 PHP 会执行A的方法

构建 [Controller] 时目标 [Interface] 不可实例化

路由未定义的 laravel 导出

Google Drive - 仅使用 FileID 获取文件的 FileSize

Laravel 自定义中间件:ERR_TOO_MANY_REDIRECTS

composer 自动加载不适用于全局函数