i am using mac os x 10.5 with apache php and mysql.

i tried below program but end up with following message..


Upload: insurance1.jpg
Type: image/jpeg
Size: 845.189453125 Kb
Temp file: /private/var/tmp/php0Vueol

Warning: move_uploaded_file(uploads/insurance1.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /Library/WebServer/Documents/php/upload_file.php on line 25

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/private/var/tmp/php0Vueol' to 'uploads/insurance1.jpg' in /Library/WebServer/Documents/php/upload_file.php on line 25
Stored in: uploads/insurance1.jpg

<html>
<body>

<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" /> <br>

<input type="submit" name="submit" value="Submit" />

</form>



</body>
</html>




<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 200000000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

    if (file_exists("uploads/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "uploads/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "uploads/" . $_FILES["file"]["name"];
      }
    }
  }
else
  {
  echo "Invalid file";
  }
?>
 Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

please ignore line 56 to 60...not a part of code. the problem is that apache server is not allowing to give write permission in the folder library/webserver/documents and...

cthoes,

Have you set good permissions on the folder you attempt to move to?

Locally Hosted
Use CHMOD from your terminal or use your desktop frontend to set the permissions.

Remotely Hosted
Use a FTP client to connect to the server. FileZilla allows you to modify permissions. Note: Maybe your hosting provider doesn't allow uploading.


Set the permissions to 777 which is all allowed:
Owner: Read/Write
Group: Read/Write
Other: Read/Write

Try that - if it works, you can change the permission to something more restrictive if you like.

In my mac. My root file is harddisk and a user account with name james.

Every time i logged into terminal i found james as root folder. I cannot go to main root folder hard disk in terminal where all system files and php files were stored(library/webserver/documents/)

so it would be great ....can any one tell me how to reach to root file .. So that
i can do some file permission changes

Prefix commands with sudo to make changes as the superuser.

Eg.

sudo chmod 777 FILE

i have tried that tooo. but still apache is not given file write permission to the folder where i had stored php files ... happy to know for any help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.