Jump to content


Photo

rename a picture


  • Please log in to reply
2 replies to this topic

#1 masgas

masgas
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 04 May 2006 - 08:57 PM

Hi... I ma trying to rename a pic that I upload into a directory and I get this error message:

Warning: rename(,.jpg) [function.rename]: Permission denied in C:\xampp\htdocs\PISOS\final\gifup2.php on line 22

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>

#2 buddaman

buddaman
  • Members
  • Pip
  • Newbie
  • 4 posts
  • LocationNorth Virginia

Posted 04 May 2006 - 09:08 PM

[!--quoteo(post=371374:date=May 4 2006, 01:57 PM:name=masgas)--][div class=\'quotetop\']QUOTE(masgas @ May 4 2006, 01:57 PM) View Post[/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.

#3 masgas

masgas
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 06 May 2006 - 08:31 AM

[!--quoteo(post=371380:date=May 4 2006, 11:08 PM:name=buddaman)--][div class=\'quotetop\']QUOTE(buddaman @ May 4 2006, 11:08 PM) View Post[/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!!!





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users