Jump to content

Recommended Posts

I have a script that uploads an image and inserts some info into my database, it works well on my home computer with apache but i get the error bellow on the net.

 

Upload: gang2.jpg

Type: image/pjpeg

Size: 5.95927734375 Kb

 

Warning: move_uploaded_file(../gallery/gang2.jpg): failed to open stream: Permission denied in /data/www/w00074/penrith/admin/process.php on line 26

 

Warning: move_uploaded_file(): Unable to move '/var/tmp/phpjBrRZe' to '../gallery/gang2.jpg' in /data/www/w00074/penrith/admin/process.php on line 26

 

Stored in: ../gallery/gang2.jpg

Your file upload was successful, to upload another file click here, to view updated gallery click here.

 

Line 26 of my code is marked below

 

<?php require_once('../../Connections/worldgym.php');
error_reporting(E_ALL);

//This gets all the other information from the form 
$photo=($_FILES['photo']['name']); 
$title=$_POST['title']; 

if ((($_FILES["photo"]["type"] == "image/gif")
|| ($_FILES["photo"]["type"] == "image/jpeg")
|| ($_FILES["photo"]["type"] == "image/jpg")
|| ($_FILES["photo"]["type"] == "image/pjpeg"))
&& ($_FILES["photo"]["size"] < 20000000))
  {
  if ($_FILES["photo"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["photo"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["photo"]["name"] . "<br />";
    echo "Type: " . $_FILES["photo"]["type"] . "<br />";
    echo "Size: " . ($_FILES["photo"]["size"] / 10240) . " Kb<br />";
     

      move_uploaded_file($_FILES["photo"]["tmp_name"], --------------------------------Line 26


      "../gallery/" . $_FILES["photo"]["name"]);
      echo "Stored in: " . "../gallery/" . $_FILES["photo"]["name"]."<br />";
  
  //Writes the information to the database 

$host="localhost"; // Host name 
    $username="******"; // Mysql username 
    $password="******;// Mysql password 	 
$db_name="wgym"; // Database name 
    $tbl_name="gallery"; // Table name 
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB");
mysql_query("INSERT INTO `gallery` VALUES (NULL,'$photo','$title')") ; 
  echo "Your file upload was successful, to upload another file <a href='upload.php'>click here</a>, to view updated gallery <a href='../gallery.php'>click here.</a> ";
      }
    }

  
else
  {
  echo "Invalid file";
  }
?>

Link to comment
https://forums.phpfreaks.com/topic/90449-permission-denied/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.