I do not understand why this is happening. I’m finding the error:
Warning : move_uploaded_file(bulklister/bulklister-2018-12-17.csv): failed to open stream: No such file or directory in C:\xampp\htdocs\vrentals\inc\csv.inc.php on line 29
Whereas I used the same code for image uploading and it works just fine. Can anyone give me some guidelines on why my file is not uploading? Do you think it’s because I’m trying to upload a CSV and not an image?
if (isset($_POST['uploadCSV'])) {
$today = date('Y-m-d');
// code for file here
$file = $_FILES['csvuploader'];
$fileName = $_FILES['csvuploader']['name'];
$fileTmpName = $_FILES['csvuploader']['tmp_name'];
$fileSize = $_FILES['csvuploader']['size'];
$fileType = $_FILES['csvuploader']['type'];
$fileError = $_FILES['csvuploader']['error'];
$fileExt = explode('.', $fileName);
$fileActualExt = strtolower(end($fileExt));
$allowed = array('csv');
if (in_array($fileActualExt, $allowed)) {
if ($fileError === 0) {
if ($fileSize < 15000000) { /*15 MB*/
$fileNameNew = "bulklister-".$today.".".$fileActualExt;
$fileDestination = 'bulklister/'.$fileNameNew;
/*Delete all files matching this filename including other file types.*/
foreach(glob("bulklister/bulklister-{$today}.*") as $match) {
unlink($match);
}
move_uploaded_file($fileTmpName, $fileDestination);
//$sqlUpload = "UPDATE modelimg SET status=0 WHERE modelid='$modelid';";
//$resultUpload = mysqli_query($conn, $sqlUpload);
}
}
}