Jump to content

Recommended Posts

hi all

 

i am uploading an image 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/adminpaji/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/adminpaji/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

Link to comment
https://forums.phpfreaks.com/topic/137386-problem-uploading-image/
Share on other sites

what os are you using? chmod command changes files permissions in linux, dno about windows.

 

hi ram

 

i have tested this on my testing server that is xampp and its working fine.

 

i m getting this error when i m testing online on linux server.

 

so what to do.

 

vineet

 

what os are you using? chmod command changes files permissions in linux, dno about windows.

 

hi ram

 

i have tested this on my testing server that is xampp and its working fine.

 

i m getting this error when i m testing online on linux server.

 

so what to do.

 

vineet

 

 

Through your FTP program, right click on the directory the images are to be uploaded to, click on "Properties".

 

Change the setting to 777 where all 3 boxes in each column are checked. This will allow php to create files in different directories.

hi premiso

 

i m using ws ftp.

 

when i right click my folder i dont get properties option there.

 

there are these below options

change folder

make folder

delete folder

transfer folder

rename folder

chmod(unix)

refresh list

folder list

 

so do i need to use anyother ftp software

 

vineet

WS_FTP, from what I remember, was pretty bad software. I tend to stick with SmartFTP or FireFTP, I do not like FireFTP too much since it is buggy, but the free version of SmartFTP is great.

 

The option in WS_FTP you want is "chmod(unix)" and change that to 0777

WS_FTP, from what I remember, was pretty bad software. I tend to stick with SmartFTP or FireFTP, I do not like FireFTP too much since it is buggy, but the free version of SmartFTP is great.

 

The option in WS_FTP you want is "chmod(unix)" and change that to 0777

 

hi premiso

 

so i download smartftp if it has free version.

 

vineet

WS_FTP, from what I remember, was pretty bad software. I tend to stick with SmartFTP or FireFTP, I do not like FireFTP too much since it is buggy, but the free version of SmartFTP is great.

 

The option in WS_FTP you want is "chmod(unix)" and change that to 0777

 

hi premiso

 

so i download smartftp if it has free version.

 

vineet

 

If you want to. That is just my FTP preference. But the above will work for you in WS_FTP. I just dislike WS_FTP because back in the day it would mess up file uploads and combine them etc. I could never get it to act right.

If you are on a shared, potentially, if you are on dedicated doubtful.

 

The only other option is to try to use the chmod function in php to change the folder permission for upload than change them back after upload.

 

hi premiso

 

yes i m on shared hosting and i dont want to take risk.

 

if you have used chmod() in your projects then can u explain how to use. here is my 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

hi premiso

 

i found chmod() and used it and getting the error.

 

Warning: move_uploaded_file(../graphics/bank_logo.gif) [function.move-uploaded-file]: failed to open stream:

 

Permission denied in /home/gads/public_html/admin/add_special_offer.php on line 12

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpksAvdQ' to

 

'../graphics/bank_logo.gif' in /home/gads/public_html/admin/add_special_offer.php on line 12

 

Warning: chmod() [function.chmod]: Operation not permitted in

 

/home/gads/public_html/admin/add_special_offer.php on line 13

 

<?php require_once("../config.php");

if(!isset($_SESSION['ADMIN_ACCESS']))
header("Location:index.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']);
chmod("../graphics/",0777); 

$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

Place the chmod before the move_uploaded_file portion...

 

hi premiso

 

i moved the chmod line before the move_upload file portion. still get the same error.

 

Warning: chmod() [function.chmod]: Operation not permitted in /home/gadgetso/public_html/admin/add_special_offer.php on line 10

 

Warning: move_uploaded_file(../graphics/lg_logo.gif) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/gadgetso/public_html/admin/add_special_offer.php on line 11

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpMr5bY8' to '../graphics/lg_logo.gif' in /home/gadgetso/public_html/admin/add_special_offer.php on line 11

 

<?php require_once("../config.php");

if(!isset($_SESSION['ADMIN_ACCESS']))
header("Location:index.php"); 
$msg="";
if(isset($_REQUEST['submit']))
{
$loc=$_REQUEST['offer_loc'];
$path=$_FILES['offer_image']['name'];
chmod("../graphics/", 0777); 
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

Place the chmod before the move_uploaded_file portion...

 

hi premiso

 

i moved the chmod line before the move_upload file portion. still get the same error.

 

Warning: chmod() [function.chmod]: Operation not permitted in /home/gadgetso/public_html/admin/add_special_offer.php on line 10

 

Warning: move_uploaded_file(../graphics/lg_logo.gif) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/gadgetso/public_html/admin/add_special_offer.php on line 11

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpMr5bY8' to '../graphics/lg_logo.gif' in /home/gadgetso/public_html/admin/add_special_offer.php on line 11

 

<?php require_once("../config.php");

if(!isset($_SESSION['ADMIN_ACCESS']))
header("Location:index.php"); 
$msg="";
if(isset($_REQUEST['submit']))
{
$loc=$_REQUEST['offer_loc'];
$path=$_FILES['offer_image']['name'];
chmod("../graphics/", 0777); 
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

 

Operation not permitted means you cannot use CHMOD through the script, you have to do it through the FTP program if you want this functionality and it will have to stay at 0777.

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.