vinpkl Posted December 17, 2008 Share Posted December 17, 2008 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 Quote Link to comment Share on other sites More sharing options...
Adam Posted December 17, 2008 Share Posted December 17, 2008 Sounds like you don't have the correct permissions. Look into chmod() .. or you can do it through your FTP program (most of the time).. A Quote Link to comment Share on other sites More sharing options...
mtb211 Posted December 17, 2008 Share Posted December 17, 2008 um have you set chmod to 777 ... sometimes that helps Quote Link to comment Share on other sites More sharing options...
vinpkl Posted December 17, 2008 Author Share Posted December 17, 2008 um have you set chmod to 777 ... sometimes that helps hi i dont know what is chmod and how to set it to 777. please clarify vineet Quote Link to comment Share on other sites More sharing options...
ram4nd Posted December 17, 2008 Share Posted December 17, 2008 what os are you using? chmod command changes files permissions in linux, dno about windows. Quote Link to comment Share on other sites More sharing options...
vinpkl Posted December 18, 2008 Author Share Posted December 18, 2008 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 Quote Link to comment Share on other sites More sharing options...
premiso Posted December 18, 2008 Share Posted December 18, 2008 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. Quote Link to comment Share on other sites More sharing options...
vinpkl Posted December 18, 2008 Author Share Posted December 18, 2008 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 Quote Link to comment Share on other sites More sharing options...
premiso Posted December 18, 2008 Share Posted December 18, 2008 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 Quote Link to comment Share on other sites More sharing options...
vinpkl Posted December 18, 2008 Author Share Posted December 18, 2008 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 Quote Link to comment Share on other sites More sharing options...
premiso Posted December 18, 2008 Share Posted December 18, 2008 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. Quote Link to comment Share on other sites More sharing options...
vinpkl Posted December 18, 2008 Author Share Posted December 18, 2008 hi premiso before changing the permission i would like to ask that is it a secure solution. will changing the permission harm my mywebsite server security. vineet Quote Link to comment Share on other sites More sharing options...
premiso Posted December 18, 2008 Share Posted December 18, 2008 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. Quote Link to comment Share on other sites More sharing options...
vinpkl Posted December 18, 2008 Author Share Posted December 18, 2008 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 Quote Link to comment Share on other sites More sharing options...
vinpkl Posted December 18, 2008 Author Share Posted December 18, 2008 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 Quote Link to comment Share on other sites More sharing options...
premiso Posted December 18, 2008 Share Posted December 18, 2008 Place the chmod before the move_uploaded_file portion... Quote Link to comment Share on other sites More sharing options...
vinpkl Posted December 19, 2008 Author Share Posted December 19, 2008 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 Quote Link to comment Share on other sites More sharing options...
premiso Posted December 19, 2008 Share Posted December 19, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.