Jump to content

Image upload unlink issue


CincoPistolero

Recommended Posts

I have a site that uploads and formats an image to my website. Currently, when I add new, it uploads the image and names it by the ID associated with the subject (ie. 8.gif). The problem occurs when I go to modify the data. The current code I have unlinks the original URL then adds a new image with no name and just the .gif extension. It is supposed to remove the old image, replace the new and reset the link. Can someone look at my code and see if they see anything wrong? Code below:

 

The 'name=' from sending page is 'photo_img', the database column name is 'photoUrl'

 

$personalPhoto=$row['photoUrl'];
if (!ereg("^[ \t\r\n]*$",$_FILES['photo_img']['name']) && is_uploaded_file($_FILES['photo_img']['tmp_name']) && !empty($_FILES['photo_img']['size'])) {
if (!ereg('default\.jpg$',$row['photoUrl']) && !ereg("^[ \t\r\n]*$",$row['photoUrl'])) {
	@unlink('/location/of/where/imageIs/stored'.$row['photoUrl']);
}
require_once('createimage.php');
createImage($_FILES['photo_img']['tmp_name'], '/location/of/where/imageIs/stored/images/aboutUsImages/'.$row['aboutUsID'].'.gif');
if (!(mysql_query("UPDATE aboutUs SET photoUrl='images/aboutUsImages/{$row['aboutUsID']}.gif' WHERE aboutUsID='{$row['aboutUsID']}'"))) {
	@unlink('/location/of/where/imageIs/stored/images/aboutUsImages/'.$row['aboutUsID'].'.gif');
} else $personalPhoto='images/aboutUsImages/'.$row['aboutUsID'].'.gif';
}

 

Thanks in advance.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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