我要上傳我的網站上的腳本,以便用戶可以上傳其上的LocalServer工作良好的XAMPP的圖像,但是當我把它上傳到我的Web服務器並上傳圖片它給我通知文件夾沒有權限,並將其chmod到777,所以我想知道如何以及在哪裏我把chmod放在這個腳本中。注意我已經在服務器上創建了「Uploads」文件夾,只是告訴我如何chmod。謝謝如何在PHP文件添加CHMOD
<?php
if(isset($_POST['upload'])) {
$allowed_filetypes = array('.jpg','.jpeg','.png','.gif');
$max_filesize = 10485760;
$upload_path = 'uploads/';
$description = $_POST['imgdec'];
$filename = $_FILES['userfile']['name'];
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
if(!in_array($ext,$allowed_filetypes))
die('The file you attempted to upload is not allowed.');
if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
die('The file you attempted to upload is too large.');
if(!is_writable($upload_path))
die('You cannot upload to the specified directory, please CHMOD it to 777.');
if (file_exists("uploads/" . $_FILES["userfile"]["name"]))
{
echo $_FILES["userfile"]["name"] . " already exists. ";
}
else
{
if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename)) {
$query = "INSERT INTO uploads (name, description) VALUES ($filename, $description)";
mysql_query($query);
echo 'Your file upload was successful!';
} else {
echo 'There was an error during the file upload. Please try again.';
}
}}
?>
你應該能夠使用了shell_exec運行從PHP在chmod – FaddishWorm