php 上传文件
sudo vi /etc/php.ini
file_uploads = on upload_max_filesize = 100m # 允许上传文件大小的最大值 post_max_size = 100M # 指通过表单 POST 给 PHP 的所能接收的最大值 max_execution_time = 600 # 每个 PHP 页面运行的最大时间值(秒) memory_limit = 128M # 每个 PHP 页面所吃掉的最大内存
$name = $_FILES["myfile"]["name"]; $type = $_FILES["myfile"]["type"]; $size = $_FILES["myfile"]["size"]; $temp = $_FILES["myfile"]["tmp_name"]; $error= $_FILES["myfile"]["error"]; if ($error > 0) { die("Error uploading file! code $error."); } else { if (is_uploaded_file($temp)) { if (move_uploaded_file($temp, "uploaded/" . $name) ) { echo "Upload complete!"; } else { print_r(error_get_last()); } } else { echo "upload_file error \n"; } }
权限问题:
chmod o+w uploaded
确认不是这些错误之后,那么应该是 SeLinux 的问题
sudo setenforce 0
上传文件应该会成功了