Welcome Guest, Not a member yet? Register   Sign In
upload config path question
#1

[eluser]joeizang[/eluser]
hi guys I would like to know, if I am writing an upload piece to store images direct in a db what do I supply in the config item 'upload path'? I don't want to get caught up in the filesystem vs db store wars so I would like to just store images related to articles in a db together with the articles and call up the articles. I have done the article part and maybe even the db just it returns jiberish not the pic. after doing some reading i discovered i was not even handling the picture. so to upload the picture into the db first i read the userguide and nada. the example there is on how to save to the filesystem. what do i do

God bless
#2

[eluser]LuckyFella73[/eluser]
First of all I would recommend to upload the file and just save the filename in your db.

But if you "have to" do it this way this article should help you:
http://www.php-mysql-tutorial.com/wikis/...abase.aspx

Basically you have to:
- upload your file (upload class)
- read the file and store in a variable (have a look at "$this->upload->data()")
- DB INSERT (column for your file have to be "MEDIUMBLOB" (says the article ..)

Hope the information is usefull for you.
#3

[eluser]joeizang[/eluser]
thanks luckyfella73,

i honestly appreciate the answer. I understand the process you laid out but my question is when uploading what do I supply as the path to store the file. since my image is a blob and I have an image table, how do i point the upload class to store the file in my database table. so when i do this in my config:
Code:
$config['upload_path'] = 'path to store image';

uploading to a folder works like a charm but to db, not so sure.

HELP PLEASE???
#4

[eluser]LuckyFella73[/eluser]
Hi,

I have never done that before but I think you have to
use the upload class to upload the file to the server
and then do a query to store the file into your database.
The file upoload class is just to upload a file to your
server. So you will have to do that in two steps.

Try to upload the file, read the file to a variable.
For the right path use the informations provided by
Code:
$this->upload->data()

// in case you don't know, following data is available:
Array
(
    [file_name]    => mypic.jpg
    [file_type]    => image/jpeg
    [file_path]    => /path/to/your/upload/
    [full_path]    => /path/to/your/upload/jpg.jpg
    [raw_name]     => mypic
    [orig_name]    => mypic.jpg
    [file_ext]     => .jpg
    [file_size]    => 22.2
    [is_image]     => 1
    [image_width]  => 800
    [image_height] => 600
    [image_type]   => jpeg
    [image_size_str] => width="800" height="200"
)
// taken from the CI userguide

After that store the file in your db by using the variable
you read the file into before.
That should work.



Sorry for not beeing more detailed but as mentioned before
I have never done that before.




Theme © iAndrew 2016 - Forum software by © MyBB