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


PHP: Upload a file to a local ubuntu server

我一直在研究一个简单的表单,将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--

可能是什么问题?

我想可能是因为没有上传文件的权限,所以我找到了这篇文章:在 var/www/image 目录中启用写入权限 Ubuntu Server

并使用:

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

是否有与本地 WAMP 服务器不同的方法将文件上传到 Linux 服务器?

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