masgas Posted May 4, 2006 Share Posted May 4, 2006 Hi... I ma trying to rename a pic that I upload into a directory and I get this error message:[b]Warning: rename(,.jpg) [function.rename]: Permission denied in C:\xampp\htdocs\PISOS\final\gifup2.php on line 22[/b]the script I use is:$link = mysql_connect("", "", ""); mysql_select_db("pisos", $link); $sql = "SELECT id, user, email FROM articulos WHERE user = '$user' AND email = '$email'"; $id = $row["id"]; $user = $row["user"]; $email = $row["email"];if(isset( $Submit )) { $ext=".jpg"; if ($_FILES['imagefile']['type'] == "image/pjpeg"){ @move_uploaded_file($_FILES['imagefile']['tmp_name'], "C:/xampp/htdocs/PISOS/final/".$_FILES['imagefile']['name']) or die ("Could not copy"); rename($name, $row["id"].$ext); echo ""; echo "Name: ".$_FILES['imagefile']['name'].""; echo "Size: ".$_FILES['imagefile']['size'].""; echo "Type: ".$_FILES['imagefile']['type'].""; echo "Copy Done...."; }I get the variables with mysql db and through the URL with:<a href='/scripts/final/picup2.php?user=$_REQUEST[user]&email=$_REQUEST[email]'>want to add a pic?</a> Quote Link to comment https://forums.phpfreaks.com/topic/9082-rename-a-picture/ Share on other sites More sharing options...
buddaman Posted May 4, 2006 Share Posted May 4, 2006 [!--quoteo(post=371374:date=May 4 2006, 01:57 PM:name=masgas)--][div class=\'quotetop\']QUOTE(masgas @ May 4 2006, 01:57 PM) [snapback]371374[/snapback][/div][div class=\'quotemain\'][!--quotec--]$link = mysql_connect("", "", ""); mysql_select_db("pisos", $link); $sql = "SELECT id, user, email FROM articulos WHERE user = '$user' AND email = '$email'"; $id = $row["id"]; $user = $row["user"]; $email = $row["email"];[/quote]First, where are you doing the actual sql execute?[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: rename(,.jpg) [function.rename]: Permission denied in C:\xampp\htdocs\PISOS\final\gifup2.php on line 22[/quote]The error looks to be permission related. Make sure the webserver has permissions to write to the location you are attempting to move,copy or rename. Quote Link to comment https://forums.phpfreaks.com/topic/9082-rename-a-picture/#findComment-33420 Share on other sites More sharing options...
masgas Posted May 6, 2006 Author Share Posted May 6, 2006 [!--quoteo(post=371380:date=May 4 2006, 11:08 PM:name=buddaman)--][div class=\'quotetop\']QUOTE(buddaman @ May 4 2006, 11:08 PM) [snapback]371380[/snapback][/div][div class=\'quotemain\'][!--quotec--]First, where are you doing the actual sql execute?The error looks to be permission related. Make sure the webserver has permissions to write to the location you are attempting to move,copy or rename.[/quote]Ok I solved the problem with:chmod("/PISOS/final/".$id.".gif", 0755);this works in local and with my paid server...the question now is: does it have any inconvenients to chmod a file, or is it normal to do so...?thanks!!! Quote Link to comment https://forums.phpfreaks.com/topic/9082-rename-a-picture/#findComment-33811 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.