Reputation: 61
php code for file uploading
$file_video_dir = 'uploads/apps/videos/';
$config['upload_path'] = $file_video_dir;
$config['allowed_types'] = 'gif|avi|mp4|3gp|mpeg|mpg|mov|mp3|flv|wmv|webm';
$config['max_size'] = 0;
$config['overwrite'] = FALSE;
$videoName = strtolower(preg_replace('/[^A-Za-z0-9\-_.]/', '_', preg_replace('/\s+/', '_', str_replace(' ', '_', time() . "_" . $_FILES['file_video']['name'])))); //time() . "_" .
$config['file_name'] = $videoName;
$this->load->library('upload',$config);
if ($this->upload->do_upload('file_video')) {
$upload_video = $final_file_video;
} else {
echo "<br/><br/>vieo error<br/><br/>";
print_r($this->upload->display_errors());
// $this->load->view('upload_form', $error);
}
html
<input type="file" name="file_video" id="file_video" class="form-control" accept="video/*">
I am getting following error while fileuploading
The filetype you are attempting to upload is not allowed.
Upvotes: 0
Views: 262
Reputation: 41
You can to go to system/libraries/upload.php file and look for
$this->_file_mime_type($_file);
and debug it by replacing it with
$this->_file_mime_type($_file);
var_dump($this->file_type); die();
Then try uploading file and see the output in the browser and check in
config/mimes.php
if the mime is not present there then add it there and revert the changes in the upload.php and it will be good to go.
Hope this helps.
Upvotes: 1