I have set up a table in mysql to store my images via upload into a blob. I am trying to display / show those images, but not sure how to do so in codeigniter.
Can someone make a suggestion on the best route / technique to do so? If there is a link to read up on this, I have been unable to find more information.
Thank you.
You can Use CI built in Upload Class for this purpose , also you can store the image path in your database by using a model along with this class.
Secondly , storing the image path in database is a much better option.
http://ellislab.com/codeigniter/user-guide/libraries/file_uploading.html
EDIT :
$this->upload->data(); this will return you the array containing all the info of your uploaded file, you can retrieve the data from this and then can use it to store the file info .
$data = $this->upload->data();
print_r($data);
Try this , to viee all the info of your uploaded file.
Related
I am trying to login and register users in codeigniter but with out using database and I would like to use json instead of database.
Can anyone give me small example that how can we do this in codeigniter.
I have worked login and registration with using database and I don't have idea of how we can do by using json.
Can any one explain me and give me small example of how to do that.
Well yes you can use helper FILE and save data in in that file.
To write / Access data, you need to do few steps:
Load File Helper
Check if File exists
Get all text and decode in array (I assume you will store in JSON format)
Fetch username/password and verify
Add new username/password in that array
Convert into JSON and save in file
How can I insert an image data in MySQL Database and then retrieve it using Golang?
Basically I want that task for upload profile picture of user in web application.
According to the my knowledge,the best solution is save image as blob object in database.Is it best solution for upload image in webapplication in golang.?
Please help me find the best solution for that.I want to find the solution in golang.I am beginner for golang programming.
converting image to a blob and save it in the database is a somewhat long process and it may cause issues sometimes. The easiest way is saving the image to a server (or a local directory) and saving the image path in the database. In that way we can access the image by using the image path in the database. This, will show how to save image path and access it and converting image to a blob and save it in the database.
Here
What is the best way to store read-only configuration in symfony?
I have some name/description pairs inside a JSON file, currently sitting in a bundle's resource directory that I'd like to use inside my controllers and views but don't want to insert into my database.
And what do you recommend for parsing / getting the values to display? Making a specific service for the DiC doesn't feel to good tbh..
Same scenario with me ,I worked with ymls file , create a yml file in config folder like product.yml , parse it in controller then send its josn to template .
And this is the right way to play with static data .
Actually I have to upload 20000 images into mysql database if I store all images to Mysql database as Blob type the performance is reduced and It will slow down if we upload other images if required.To avoid this problem I am storing all images into folder and their path's into mysql database table.and retriving these images with pagination .
now data is showing in table but images are not displaying.
String sb1 = new String("file://");
String sb2=new String(user.getPlaceImage());
out.println("<td><img src="+sb1.concat(sb2)+" width='70' height='50' /></td>");
If there is any alternative way to deal with this problem?
Here is a basic alternative technique that I use to serve images to users:
Create a folder outside your website root so users won't have direct access to the files using HTTP. Let's say you already have a database table that contains URI to all the images. Create a interface file, for instance: getimage.jsp?id=42 that serves user the requested image file. Also, if you are storing relative URLs in the database you need to be extra careful because you might be trying to read the file from a wrong path in relation to your JSP file that's trying to access the image.
I would like to store images in my mySQL database using the CodeIgniter PHP framework.
How do I write and read the image?
Thank you.
You will have to use the file uploading class of CI to upload the files and use the models to save them to the database, here are related resources:
File Uploading Class
Models
It's considered bad practice to store the actual image files directly in a database. Instead you can just store a path to the file in the database and store the file in a directory on the server.
AstaHost Forums
Best approach for storing uploaded image
CodeIgniter - Uploading an Image through a form, store the location of the image in database