PHP:将文件上传到本地 ubuntu 服务器

标签 php ubuntu file-upload chmod

我一直在研究一个简单的表单,将 Excel 文件上传到服务器并对其进行操作,然后让我选择下载它。

在我的 WAMP 服务器上它运行完美!

将其上传到本地 Ubuntu 服务器后,将其发送到处理它的文件后,我在“网络”上收到此错误:

Request URL:http://10.0.0.66/PHPExcel/main.php
Request Method:POST
Status Code:500 Internal Server Error
Remote Address:10.0.0.66:80
Response Headers
view source
Connection:close
Content-Length:1
Content-Type:text/html; charset=UTF-8
Date:Wed, 02 Mar 2016 16:51:42 GMT
Server:Apache/2.4.12 (Ubuntu)
Request Headers
view source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:10621
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryTlu6BO9uHeeHBF5X
Cookie:ci_session=1ce8fcaf8b36c7a2cf254077b1682edca9e771e3
Host:10.0.0.66
Origin:http://10.0.0.66
Referer:http://10.0.0.66/PHPExcel/
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36
Request Payload
------WebKitFormBoundaryTlu6BO9uHeeHBF5X
Content-Disposition: form-data; name="file"; filename="0103.xlsx"
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet


------WebKitFormBoundaryTlu6BO9uHeeHBF5X
Content-Disposition: form-data; name="MOS"

android
------WebKitFormBoundaryTlu6BO9uHeeHBF5X--

可能是什么问题?

我想可能是因为没有上传文件的权限所以我找到了这个帖子: Enabling write permissions Ubuntu Server in var/www/image directory

并使用:

root@server:/var/www/html# sudo chmod 664 *
root@server:/var/www/html# sudo find . -type d -exec chmod 755 "{}" \;

将文件上传到 Linux 服务器和本地 WAMP 服务器有什么不同的方法吗?

最佳答案

对于上传文件所在的特定文件夹,请确保您拥有 777 权限,如 Indrasinh 所建议的

关于PHP:将文件上传到本地 ubuntu 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35753531/

相关文章:

php - 缓存 PHP 简单 HTML DOM 解析器

php - 如何使用 xampp 从本地计算机访问 Windows Server 2012 r2 上的数据库?

node.js - 为什么 {"files":[]} show up when try to run blueimp uploader?

angular - ng2-file-upload 访问控制来源问题

javascript - Meteor:无法使用 CollectionFS 将图像上传到 S3

php - 从 Laravel 中的对象数组中获取值

php - 具有 3 个条件的 Wordpress 元查询

ubuntu - 服务 upstrat 进程退出,错误代码

php - Python wordpress xmlrpc -32700 错误与 wordpress4.8

android - 如何在 Linux 服务器(Ubuntu)上安装 Android 命令行工具