你好我试图上传一个视频到我的文件夹,我已经搜索了问题已经有了答案,并尝试了所有这些,似乎没有一个工作。 我想要在同一输入中上传图像和视频
这是我视图中的代码
$('#upload_image_button').on('click', function(){
var imageFile = $('input[name=upload_image_input]');
var imageToUpload = imageFile[0].files[0];
var imageName = $('#upload_image_name').val();
$('#Upload_Image').val(imageName);
if(imageToUpload) {
//Provide the form data that would be sent to server through ajax
var formData = new FormData();
var uploadURI = '<?php echo base_url('uploadImage'); ?>';
formData.append('upload_image_input', imageToUpload);
//Upload the file using ajax
$.ajax({
type: 'POST'
, url: uploadURI
, data: formData
, processData: false
, contentType: false
, success: function() {
var image = '<?php echo base_url("assets/images/'+ imageName +'"); ?>';
//$('#profile_pic').attr('src', image);
Materialize.toast('Image Attached', 4000);
}
, error: function(errorw){
Materialize.toast('Something went wrong. Please try again', 4000);
}
});
}
else{
Materialize.toast('Field Empty', 4000);
}
});
这是我控制器的代码
public function uploadImage(){
$config['upload_path'] = 'assets/files';
$config['allowed_types'] = 'mp4|3gp|jpg|png|jpeg';
$config['max_size'] =0;
$config['max_width'] =0;
$config['max_height'] =0;
$this->upload->initialize($config);
if ($this->upload->do_upload('upload_image_input')) {
//File upload
$uploadData = $this->upload->data();
$filename = $uploadData['file_name'];
// $this->loginmodel->upload_model($filename,$account_id);
}
}