I have a controller in CI which allows me to upload files to my database. It works fine locally. I setup CI on GoDaddy, changed permissions, changed database configs etc.
Now when I try to upload a file, I can select the file and it gets to 100% uploaded -- but it doesn't save. Permissions on the directory files get uploaded to are 777 (for testing right now). I get the following in the webdev console:
Error in event handler for (unknown): TypeError: Cannot read property 'state' of null
at CSRecorder.onQueryStateCompleted (chrome-extension://cplklnmnlbnpmjogncfgfijoopmnlemp/content_scripts/recorder.js:45:13)
at extensions::messaging:327:9
at Function.target.(anonymous function) (extensions::SafeBuiltins:19:14)
at Event.dispatchToListener (extensions::event_bindings:386:22)
at Event.dispatch_ (extensions::event_bindings:371:27)
at Event.dispatch (extensions::event_bindings:392:17)
at dispatchOnMessage (extensions::messaging:294:22) extensions::event_bindings:375
GET http://mywebsite.com/index.php/assets/uploads/files/dark_bg.png 404 (Not Found) jquery-1.10.2.min.js:4
event.returnValue is deprecated. Please use the standard event.preventDefault() instead.
I also get a popup that says "The page at mywebsite.com says: 6"
.
Here is the controller (again, it's working on my local Windows machine):
public function photo_upload()
{
try{
$gc = new grocery_CRUD;
$gc->set_table('photography')
->set_subject('Image')
->required_fields('image_path')
->columns('image_path','image_name');
$gc->set_field_upload('image_path','assets/uploads/files');
$gc->unset_fields(array('image_date','image_extension'));
$gc->change_field_type('image_name','invisible');
$gc->callback_before_insert(array($this,'rename_image'));
$output = $gc->render();
$this->_example_output($output);
}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}
function rename_image($post_array)
{
if (!empty($post_array)) {
//Remove image extension from image name
$img_name = preg_replace('/\.[^.]+$/', '', $post_array['image_path']);
//Remove codeigniter id from image name
$img_name = substr($img_name, 6);
$post_array['image_name'] = $img_name;
return $post_array;
}
}
Are you 100% sure the directory exists and the image_path you are pointing to exists?
You could set an absolute path for that:
And can you tell me what your CI error logs say? In application/logs/log-*.php What i don't understand about the error you are getting is the error popup doesn't seem to be coming from this piece of code. I was expecting this message to popup:
But instead you get:
"The page at mywebsite.com says: 6"
.