need how to store image that is been uploaded in the database with attaching some description and then retrieving like a |
[eluser]ebot[/eluser]
hello i will be grateful if some let me know how to store upload images into the database and then retrieves it and pass it to the view like how a blog is being done, any code examples will be highly appreciated from me, i want to upload and image, store it in the database together with a brief description of this image and then display it on the view. thanks for the help Ebot.T
[eluser]Teks[/eluser]
The first part of your question - that is, how to get the file from the user and store it in the database - is partially answered in the User Guide, here: File Uploading Tutorial The tutorial shows you how to save the uploaded images into a directory, not a database. However, storing the file in a database - instead of a directory - is trivial, once you know how to process the uploaded data. Just place the uploaded data into a BLOB/BINARY field in your database. Note also that the code used in the above tutorial can be made even simpler if you use the functions available in the Form Helper: Form Helper Documentation I am, however, having the same problem as you, in regards to redisplaying the saved file(s). My script is saving the image file(s) in the database, but now I want to redisplay them inside a view. What is the procedure for that? If one of the more experienced CodeIgniter developers could give us some guidance, I would be most thankful!
[eluser]praxedis[/eluser]
$imagebytes = $row[imgdata]; header("Content-type: image/jpeg"); print $imagebytes; |
Welcome Guest, Not a member yet? Register Sign In |