I'm developing a simple web app and I just want to allow the user to upload some pictures.
should I just store the picture url on my database table or should I upload the whole picture?
how can I validate the size of the picture being uploaded?
how can I upload the picture from my controller?
thank you all!
I would NOT store the image data in the database. I would create a Behavior that will upload the image to the image directory and store a reference to that image. The behavior can then handle size, mime type, etc. Then add a file upload form to the controller and when the data goes to the model to be saved, it will automatically upload the image and put it where it goes.
If you do not want to build your own, here is a very popular behavior that someone has built.
https://github.com/jrbasso/MeioUpload
Or you could try this simple way of doing it (check the readme.md file) :
https://github.com/malikov/cakephp2.0-image-upload
Related
I study the phoenix, create an application that loads the image on aws s3, and then displays it. I was able to upload the image to the cloud, but now it is not clear how to display it to the user on the page (I do not want to make public link to these images in the cloud). I was looking for information on this issue, but did not find anything useful.
From the clouds I get the file as binary data. Do I need to create some of these data is a temporary file that will be displayed on the page? I can display the image as base64, but I think this is not the best way. I would appreciate advice.
Since you've already fetched the image to a binary, you can just send it directly to the client with the appropriate content type and the browser will render it as an image. For example, to fetch and send the png at https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png:
def index(conn, _params) do
image = HTTPoison.get!("https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png").body
conn
|> put_resp_header("content-type", "image/png")
|> send_resp(200, image)
end
If you open this in your browser, you'll see the image being rendered correctly because of the content-type header.
The idea is that i will create a file in the app and store some data in it.
I want for the end user to be able to download that file from the iOS device to his mac/pc.
Is this somehow possible? Where should i put the file for the user to be able to download it via itunes?
Here is good tutorial you can use:
Tutorial
It is important to know, that in iOS, when your user needs to create file, you do not need to care where to save it.
Another possibility for you might be to avoid saving data as file. For example, if your data is picture:
UIImage send to email
I am creating app to display image from web services on iPad
I use FGallery to create photo gallery on my app and I retrieve binary image form web services and convert it to UIImage.
How can I add images to FGallery?
I am hoping that someone out there might have a solution that can perform this task, or if anyone could point me in the right direction, I would really appreciate it!
FGallery is current written to load images from the application bundle or web server via URL. Because you cannot change the application bundle at run-time, you will need to change FGallery to read images from <Application_Home>/Documents/ folder. Once that is accomplished, you will then save your new UIImage to the application documents folder and update the NSArray *localImages in the RootViewController.
I need some advice. In my application people can upload images. I will store the images on a server. I want to make a photo gallery where you can see all uploaded images. Every user has a account. And it will download all uploaded images.
The point is that when you uploaded 1 image it has to download 1 image. But when you upload 10 or more the app will have to download all images and cache the images to your device.
What is the best way to download all images and keep the app running without getting stuck. Also what is the best way to cache all images.
If you want to create some photo gallery apps, check out this open source sample.
Created by Michael Waterfall, which includes photo gallery from images stored on server or locally.
You can modify the code as per your project requirements. And it is easy to handle the images.
How can we upload an image while registering the customer in zen-cart?
I would like to provide an option to upload the customer's image on registering with a zen-cart application. Is there a plug in for that?
Not that I've heard of. You would need to extend the customer_info table to hold the image file name, add an extra field to the account creation page and then handle the uploaded file in the account creation pages includes/modules/pages's header_php.php file.
However, there is a Zen Cart file upload class that provides an easy to use toolset for the last step. The admin banner page offers a good example to copy from.