Problem In Renaming A File

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
haseebmaqsood
Forum Newbie
Posts: 15
Joined: Sat Jun 16, 2007 10:55 am

Problem In Renaming A File

Post 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);
}
User avatar
SpecialK
Forum Commoner
Posts: 96
Joined: Mon Sep 18, 2006 3:49 pm

Re: Problem In Renaming A File

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Problem In Renaming A File

Post 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?
Post Reply