php - Change filename when uploading array -


i uploading files folder, there uploading path of files database, executed using array using php. before upload how can change uploaded file name random/unique?

php:

<?php    if(isset($_files['file_array'])){      $name_array = $_files['file_array']['name'];      $tmp_name_array = $_files['file_array']['tmp_name'];      $type_array = $_files['file_array']['type'];      $size_array = $_files['file_array']['size'];      $error_array = $_files['file_array']['error'];                	  $conn_info = "host= port= dbname= user= password=";  $dbconn = pg_connect($conn_info) or die('could not connect:' . pg_last_error());  		 echo"<br/>sucessful connection";             for($i = 0; $i < count($tmp_name_array); $i++){      if(move_uploaded_file($tmp_name_array[$i], "uploads/".$name_array[$i])){          // path          $path = "uploads/".$name_array[$i];          echo $name_array[$i]." upload complete<br>";          // insert query           $query = "insert example (path) values ('".$path."') ;";          pg_query($dbconn, $query);      } else {          echo "move_uploaded_file function failed ".$name_array[$i]."<br>";      }  }  }	  	  	echo "<br/> file uploaded postgresql";  	pg_close();    	?>


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -