Jump to content

rename a picture


masgas

Recommended Posts

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>
Link to comment
https://forums.phpfreaks.com/topic/9082-rename-a-picture/
Share on other sites

[!--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.
Link to comment
https://forums.phpfreaks.com/topic/9082-rename-a-picture/#findComment-33420
Share on other sites

[!--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!!!
Link to comment
https://forums.phpfreaks.com/topic/9082-rename-a-picture/#findComment-33811
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.