php - File larger than 1mb upload again and again in the upload folder
Get the solution ↓↓↓If we upload a file larger than 1 MB it uploads accurately but upload the same file again and again without showing any notification. Upload Folder showssame file uploaded again and again
. Can you please help me out to resolve this issue?
$this->load->language('extension/ticketform');
$json = array();
foreach ($this->request->files as $key => $value) {
$_FILES['img']['name'] = $value['name'];
$_FILES['img']['tmp_name'] = $value['tmp_name'];
}
if (!empty($_FILES['img']['name'])) {
$imageCount = count($_FILES['img']['name']);
//echo "<pre>";print_r($imageCount);exit;
for($i=0;$i<$imageCount;$i++) {
if ($_FILES['img']['tmp_name'][$i] == '') {
continue;
}
//Get file extension
$filename = $_FILES['img']['name'][$i];
$extension = pathinfo($filename, PATHINFO_EXTENSION);
$newname = date('YmdHis', time()) . mt_rand() . '.'. $extension;
move_uploaded_file($_FILES['img']['tmp_name'][$i], DIR_DOWNLOAD . $newname);
$json['filename'][] = $newname;
$json['mask'] = $filename;
}
} else {
$json['error'] = '<strong>Error!! </strong> Please select a file.';
}
$json['success'] = $this->language->get('text_upload');
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: 403 this action is unauthorized.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.