Hi,
I'm trying to create an upload utility in my own shopping cart software that allows the store owner to upload buttons for the cart system. For each button I have made a default .png image and store it in a folder at root/images/buttons. I want whatever png image is uploaded to be renamed to a specific name like go.png. So they could upload any image thats a png and it will automatically rename it to go.png. This will overwrite the current go.png in the folder and their button will be updated. I do not want to do a database storage of images becuase the database is already 61 tables and I need to cut down on the size of things and just make it simple. Here's the code I have so far. but I am getting the error:
Warning: rename($file_name,go.png) [function.rename]: No such file or directory in /home/papermom/public_html/manager/settings/buttons2.php
<?php
// Your file name you are uploading
$file_name = $HTTP_POST_FILES['ufile']['name'];
rename( '$file_name', 'go.png' );
$path= "../images/buttons/";
if($ufile !=none)
{
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
echo "Successful<BR/>";
echo "File Name :".$new_file_name."<BR/>";
echo "File Size :".$HTTP_POST_FILES['ufile']['size']."<BR/>";
echo "File Type :".$HTTP_POST_FILES['ufile']['type']."<BR/>";
}
else
{
echo "Error";
}
}
include("../includes/header.inc.php");
?>
<p class="pageTitle">Customize Store Buttons</p>
<?php
if(isset($msg)){
echo stripslashes($msg);
} else {
?>
<p class="copyText">Edit Buttons</p>
<?php } ?>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form action="buttons2.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td><strong>Single File Upload </strong></td>
</tr>
<tr>
<td>Select file
<input name="ufile" type="file" id="ufile" size="50" /></td>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value="Upload" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
<?php include("../includes/footer.inc.php"); ?>