permission denied for upload – PHP

  php

Q(Question):

hi all

i am uploading an image on live linux hosting server and getting the below error


Warning: move_uploaded_file(../graphics/home_bigad2.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/gads/public_html/vineet/admin/add_special_offer.php on line 12
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpXjKkp7' to '../graphics/home_bigad2.jpg' in /home/gads/public_html/vineet/admin/add_special_offer.php on line 12

This is my php code


<?php require_once("../config.php");
$msg="";
if(isset($_REQUEST['submit']))
{
$loc=$_REQUEST['offer_loc'];
$path=$_FILES['offer_image']['name'];
move_uploaded_file($_FILES['offer_image']['tmp_name'], "../graphics/" . $_FILES['offer_image']['name']);
$qry="insert into special_offers(location,offer_image) values('$loc', '$path')";
if(mysql_query($qry))
$msg="Offer Inserted successfully";
else
$msg="Error Inserting Offer";
}
?>

vineet

A(Answer):

Make sure the folder you’re moving to file to has the correct permissions.

A(Answer):

@Markus

hi markus

how do i set corect permission. can u say in detail

vineet

A(Answer):

@vinpkl

Do you use an FTP for your site files – if so, what FTP program, or are they stored locally on your computer?

If they’re stored on your computer, you can right-click a folder or file, select properties, and then, from the security tab, change it’s permissions. – This is for Windows.

My FTP allows me to do the same thing; right-click the folder/file I want to edit, then change the permissions from their.

A(Answer):

@Markus

hi marcus

i m using ftp software.

tell me what to write in permission after right click properties. at present its 755

vineet

A(Answer):

@vinpkl

Try changing it to 766.

A(Answer):

@Markus

hi markus

just a question in my mind that

will changing permission harm my server or website security in any way.

vineet

LEAVE A COMMENT