Page 1 of 1

Problem In Renaming A File

Posted: Mon Mar 17, 2008 11:39 am
by haseebmaqsood
Kindly Solve My Problem

Warning: rename(d:\xampp\htdocs\SAP/product_image/160px-Angelina_jolie_lugar.jpg,d:\xampp\htdocs\SAP/product_image/7.image/gif) [function.rename]: No such file or directory in D:\xampp\htdocs\SAP\cp\addProduct.php on line 30

Path Of File:D:\xampp\htdocs\SAP\product_image

$ROOT_PATH="d:\\xampp\\htdocs\\SAP";
$fname=$_FILES['userfile']['name'];
$ftype=$_FILES['userfile']['type'];
if(file_exists($ROOT_PATH."/product_image/$fname"))
{
rename($ROOT_PATH."/product_image/$fname",$ROOT_PATH."/product_image/$id".".".$ftype);
}

Re: Problem In Renaming A File

Posted: Mon Mar 17, 2008 3:10 pm
by SpecialK
I think it might be a problem with your slashes on your path. You have both forward and backslashes

Also, as another thing, your extension for the rename "7.image/gif" I assume would need to be parsed from the filetype

Re: Problem In Renaming A File

Posted: Mon Mar 17, 2008 3:58 pm
by RobertGonzalez
haseebmaqsood wrote:Kindly Solve My Problem
Perhaps you could have put it this way:
Could someone please help me figure out what is going wrong with this code?
Are your permissions correct for reading/writing to files on your server?