PHPとLinuxが初めてです。私はファイルアップロードスクリプトを設定しようとしているときに問題があります。 !is_writableで停止します。私はこれがサーバー上のアクセス許可の問題だと思っていますが、私は777に設定されています。何か不足していますか?PHPスクリプトとUbuntuサーバの権限問題
サーバは、ローカルアクセスを持つ仮想マシンとして設定されたUbuntuサーバです。ページ
ini_set('error_reporting', E_ALL);
echo "<br/>";
//This gets all the other information from the form
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$pic=($_FILES['photo']['name']);
//This is the directory where images will be saved
$target = "testimages/";
$allowed_filetypes = array('.jpg','.bmp','.png'); // These will be the types of file that will pass the validation.
$target = $target . basename($_FILES['photo']['name']);
$filename = $_FILES['photo']['name']; // Get the name of the file (including file extension).
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename.
// Check if the filetype is allowed, if not DIE and inform the user.
if(!in_array($ext,$allowed_filetypes))
die('The file you attempted to upload is not allowed.');
// Check if we can upload to the specified path, if not DIE and inform the user.
if(!is_writable($target))
die('You cannot upload to the specified directory, please CHMOD it to 777.');
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
//Tells you if its all ok
echo "The file ". basename($_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
// Connects to your Database
mysql_connect("localhost","phptestuser","ct6697") or die(mysql_error()) ;
mysql_select_db("Testing") or die(mysql_error()) ;
//Writes the information to the database
mysql_query("INSERT INTO employees (name, email, phone, pic) VALUES ('$name', '$email', '$phone', '$pic')");
から
コードは、以下の両方の回答を試してみましたが、まだ動作していない、他の提案? LS -alから
リスト:
drwxrwxrwx 9 root root 4096 Nov 7 16:09 .
drwxr-xr-x 14 root root 4096 Nov 7 16:53 ..
drwx------ 2 www-data www-data 4096 Nov 7 15:05 .gnupg
-rwxrw-rw- 1 yoderman94 www-data 2464 Nov 8 07:31 Add.php
-rwxrw-rw- 1 yoderman94 www-data 629 Nov 7 15:27 ImageUpload.php
-rwxr--r-- 1 yoderman94 yoderman94 2115 Nov 7 15:45 PHP_Test.php
drwxr-xr-x 2 yoderman94 yoderman94 4096 Nov 1 14:39 _mmServerScripts
-rw-r--r-- 1 root root 177 Oct 27 11:32 index.html
-rw-rw-r-- 1 yoderman94 yoderman94 44 Nov 1 10:19 phpinfo.php
drwxrwxrwx 2 www-data www-data 4096 Nov 7 16:09 testimages
drwxrwxrwx 2 www-data www-data 4096 Nov 7 15:08 tmp