Jump to content

How to rename file name in DB...???


aris1234

Recommended Posts

How to rename file name in DB...???

 

this my code, but this code only save image to folder, can't rename file in DB :

 

<?php

//Сheck that we have a file
$folder = "../property/$spid";
if(!file_exists($folder))
{
   mkdir($folder);
}
$sql = "UPDATE `$table` SET str_image1='$simage1' WHERE int_prop_ID='$spid'";
}
		if(mysql_query($sql, $conn) == false)
			  {
				exit(mysql_error());
			  }
		  else
			{
				$property_id = mysql_insert_id();
			}

	// Process image
		for($i = 0; $i < count($_FILES["file"]["name"]); $i++)
			{
			 // Update row
				$filename = $_FILES["file"]["name"][$i];		
				$sql = "UPDATE properties ".
		   			   "SET str_image". ($i + 1) ."= '$filename' ".
		   			   "WHERE int_prop_ID = $property_id ";
				mysql_query($sql, $conn);		

			// Move file
			$tmp_filename = $_FILES["file"]["tmp_name"][$i];
			move_uploaded_file($tmp_filename, $folder ."/". $filename);
		   }

header( 'Location: view.php' );

?>

Link to comment
https://forums.phpfreaks.com/topic/55217-how-to-rename-file-name-in-db/
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.