I'm using uplodify with CodeIgniter.
I have 2 database settings. One is from localhost another one is from http://phpmyadmin.co.
If I select database as phpmyadmin.co server uploading is working fine. But if I select my localhost database then then uploadify returns http 500 error or IO error.
But the file is uploaded successfully to the folder but always return onUploadError function
Using the following code to upload
$(function() {
$('#file_upload').uploadify({
'formData' : {
'timestamp' : '<?php echo $timestamp;?>',
'token' : '<?php echo md5('unique_salt' . $timestamp);?>',
'wallmount_id' : $('#id').val(),
'sessionID' : '<?php echo session_id(); ?>',
'user' : '1'
},
'swf' : './uploadify.swf',
'uploader' : 'home/save_video',
'fileTypeDesc' : 'Video Files',
'fileTypeExts' : '*.mp4; *.avi; *.webm; *.3gp; *.mov; *.mpeg; *.3gp; *.wmv',
'auto' : false,
'buttonText': 'Select Video File',
'onUploadStart' : function(file) {
$("#file_upload").uploadify("settings", "formData", {'id' : $('#id').val()});
},
'onUploadSuccess' : function(file,data,response) {
alert(data);
},
'onUploadError' : function(file, errorCode, errorMsg, errorString) {
alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
}
});
});
And this is controller function to save uploaded file
public function save_video() {
$verifyToken = md5('unique_salt' . $_POST['timestamp']);
if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
$config = set_upload_options('uploads/videos');
$this->load->library('upload');
$new_name = $_POST['id']."_".time()."_".$_FILES["Filedata"]['name'];
$config['file_name'] = $new_name;
$this->upload->initialize($config);
//$tempFile = $_FILES['Filedata']['tmp_name'];
$targetFile = 'uploads/videos/'.$new_name;
//$this->upload->do_upload('Filedata');
if (!$this->upload->do_upload("Filedata")){
$this->session->set_flashdata('message', array('message' => $this->upload->display_errors(), 'title' => 'Error !', 'class' => 'danger'));
}
else {
$upload_data = $this->upload->data();
$data['video_path'] = 'uploads/videos/'.$file_name;
$result = $this->home->save_videos($data);
}
}
}
and my model code is
function save_videos($data) {
$result = $this->db->insert('videos', $data);
if($result) {
return $this->db->insert_id();
}
else {
return false;
}
}