上周終於到了最後一步,成功完美運行后發現文件無法上傳,馬上日志定位問題:
[client 192.168.0.114:53645] PHP Warning: move_uploaded_file(./ImageHouse/16448_184733.jpg): failed to open stream: Permission denied in /var/www/html/obs/bukkenPhotoUpload.php on line 55
無權限,在網上找了下原因,應賦予777可讀寫權限
chmod 777 obs
然後還是不行!
[client 192.168.0.114:53645] PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /var/www/html/obs/bukkenPhotoUpload.php on line 37, referer: http://192.168.0.44/obs/bukkenPhoto.php?r=16448
我也不明白這跟時區有什麽關係,還是先調整下時區吧
php.ini配置文件中找到: ;date.timezone =
date.timezone = "Asia/Tokyo"
然後大戲來了:
[client 192.168.0.114:53645] PHP Warning: move_uploaded_file(./ImageHouse/16448_184733.jpg): failed to open stream: Permission denied in /var/www/html/obs/bukkenPhotoUpload.php on line 55, referer: http://192.168.0.44/obs/bukkenPhoto.php?r=16448
還是不行,這回有點蒙,
多虧多虧,我安裝的是CentOS配GUI,這個時候彈窗了
點開詳情
這塊應該是apache沒有權限寫入,而且這裏面也給出了怎麽賦權的命令,簡直棒呆!
ausearch -c 'httpd' --raw | audit2allow -M my-httpd
semodule -i my-httpd.pp
然後處理文件夾的問題,同樣也給出了命令:
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/obs/ZumenFile'
restorecon -v '/var/www/html/obs/ZumenFile'
問題完美解決