Jump to content

Uploads and renaming files


iceblox

Recommended Posts

Hi Guys,

 

I have an upload script and im trying to rename the file based on the count of images already in the database.

 

I have tried a number of different things and keep failing.

Has any got any ideas?

 

This is the code..

 

	if(!empty($_POST["addbutton"])) {
	$images = array();
	while(list($key, $value) = each($_FILES["images"]["name"])) {
		if(!empty($value)) {
			$tmp = $_FILES["images"]["tmp_name"][$key]; 
			$new = "img/gallery/images/$value";
			if(copy($tmp, $new)) $images[] = $value;
		}
	}

                $sql = "INSERT INTO ".$prefix."_galleryimage (catid, image, thumb, title, active) VALUES (
			'".forSql($_POST["catid"])."',
                '".$images[0]."',
                '".$images[1]."',
                '".forSql($_POST["title"])."',
                '".forSql($_POST["active"])."')";

	$result = $db->sql_query($sql);

	if($result)
		$status = "<b>".$_POST["title"] . " added successfully</b>";
	else
	{
		print_r($db->sql_error($result));
		$status = "<b>Error could not add news. " . var_dump($db->sql_error($result),true);
	}
}
}

Link to comment
https://forums.phpfreaks.com/topic/105003-uploads-and-renaming-files/
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.