File upload

QuestionsFile upload
Samsun asked 10 years ago

Mr Abu,

I have problem when i use phpgrid in codeigniter with upload file. When without CI, my code working very well.

How if i want to save the file in database?

FYI, i use Oracle.

Regards,
Samsun

3 Answers
Abu Ghufran answered 10 years ago

To save file in DB, you need to write custom code with on_insert OR on_update event handlers.
For e.g.

// use events if you need custom logic for upload
$e["on_insert"] = array("add_invoice", null, true);
$g->set_events($e);

// callback for add
function add_invoice($data)
{
$upload_file_path = $data["params"]["note"];
// …
}

This callback contains the filename with path, that is uploaded. You can read it's content using file_get_contents and execute a SQL to save in database.

In CI, the querystring are removed by default to make user friendly urls. That may be causing the issue.
try appending QSA in htaccess, when it sends requests to index.php. There may be other cases, but you need to debug using firebug & print_r($_POST); inside code.

Samsun answered 10 years ago

would you like to send me an example code?

Abu Ghufran answered 10 years ago

Hello,

I'm sorry but the code is not there for file uploading in database.
You can refer editing/file-upload.php. It contains event handlers placeholders for your custom code.

Your Answer

12 + 14 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?