$org_file_name = $_FILES['file1']['name'];
$file_size = $_FILES['file1']['size'];
$ext = strtolower(pathinfo($org_file_name, PATHINFO_EXTENSION));
$file_path = 'docs/';
$rand = rand(111,999);
if($ext == 'csv')
{
if(file_exists($file_path))
{
$file_path = 'docs/'.$org_file_name;
}
if(!move_uploaded_file($_FILES['file1']['tmp_name'],$file_path))
{
die ('<script> alert("file not uploaded successfully."); </script>');
}
}
else
{
die ('<script> alert("Uploaded only CSV files."); </script>');
}
In my code, csv files uploads but it doesn't rename it before saving into the database? I get the following error message:
Parse error: syntax error, unexpected ';' on line 28 Parse error: syntax error, unexpected 'echo' (T_ECHO) on line 29
How can I rename them? and how can I fetch this file from database.