emediastudios Posted February 11, 2008 Share Posted February 11, 2008 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 More sharing options...
vbnullchar Posted February 11, 2008 Share Posted February 11, 2008 is the directory writable? Link to comment https://forums.phpfreaks.com/topic/90449-permission-denied/#findComment-463739 Share on other sites More sharing options...
cooldude832 Posted February 11, 2008 Share Posted February 11, 2008 chmod($directory,0776) should work Link to comment https://forums.phpfreaks.com/topic/90449-permission-denied/#findComment-463752 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.