When I try to upload photos using Dropzone, the error message mentioned above appears, indicating an issue with the upload path. I have double-checked the path settings in my code, and they seem to be correct. Despite this, the error persists.
What's the reason? I am currently working on implementing Dropzone.js for handling file uploads in my web application. However, I am encountering an issue where the error message "Error uploading photos: The upload path does not appear to be valid" is displayed.
I am using PHP codeigniter3 framework and PHPMyadmin for my backend.
public function uploadlandphotos()
{
$response = array();
$parcelnum = $this->input->post('parcelnum');
$parcelnum = str_replace('.', '', $parcelnum);
if (!empty($_FILES['land_photos']['name'])) {
$upload_path = FCPATH . 'uploads/user_kyc/land_photos/';
if (!is_dir($upload_path)) {
if (!mkdir($upload_path, 0777, true)) {
$response = array('msg' => 'Failed to create the upload directory', 'status' => false);
echo json_encode($response);
return;
}
}
$config['upload_path'] = $upload_path;
$config['allowed_types'] = 'jpg|jpeg|png|mp4|avi|mov';
$config['max_size'] = 25600;
$this->load->library('upload', $config);
if ($this->upload->do_upload('land_photos')) {
$fileData = $this->upload->data();
$originalFileName = str_replace(' ', '_', $fileData['file_name']);
$newFileName = $parcelnum . '_' . $originalFileName;
$newFilePath = $upload_path . $newFileName;
if (rename($fileData['full_path'], $newFilePath)) {
$response = array('msg' => 'Photos Uploaded Successfully', 'status' => true, 'file_name' => $newFileName);
} else {
$response = array('msg' => 'Error renaming the file', 'status' => false);
}
} else {
$error = $this->upload->display_errors();
$response = array('msg' => 'Error uploading photos: ' . $error, 'status' => false);
}
} else {
$response = array('msg' => 'No file selected', 'status' => false);
}
echo json_encode($response);
}
I was able to resolve the issue by modifying my server-side code. Specifically, I replaced the line