I know this is an old post. But many visitors to this page are getting nothing related to the question. Especially for a newbie.
How to upload and store images or files in our website:
For a static website there maybe no problem since the file storage for some share hostings are still adequate. The problem comes from a dynamic website when it gets bigger. Bigger database can be handled, but bigger file quantities, such as images, becomes a problem. There are two types of images in a website:
Images that come from the administrator in a dynamic blog. Usually, these images have been optimized before upload.
Images from users. In case users are allowed to upload images such as avatars, or users can create blog content and input some images from text editor. In this kind of images it is difficult to predict the size. Users can upload big images just for small content resizing the view size but not the actual image size.
By ignoring item no. 1 above, quick solution for item no. 2 can be temporary solved by the following tips if we don't have image optimizer functionality in our website :
Do not allow users to directly upload from text editors by redirecting them to an image gallery. On this page users must upload files in advance before they can embedded in the content. This method is called File Manager.
Use a crop image function for users to upload images. This will limit the image size, even for users who upload very big files. The final image is the result of the cropped image. We can define the size in server side and accept only for example 500Kb or lower.
Now, that is only temporary. For a final solution, the question is repeated :
- How to handle a big images storage?
- Resize or change the extension.
- How a big or medium website or e-commerce handle the file storage for their images?
What can we do then :
Migrate from share hosting VPS. Not enough? Then upgrade to Dedicated one.
Create your own server for file storage. Google how to do it. This is not as difficult as you think. Some people do it for their website.
The easy way is use a CDN file storage service.
Okay, 1 and 2 is little bit expensive. But not 3. I think is the best solution.
Some CDN services allow you to store as many web files as you want.
Question, "how to upload files to CDN from our website?"
Don't worry, once you register, usually free, you will get guidance how to upload files and get their link from/to your website. You will get an API and more. It's easy.
Some providers give us a free service for 14 days with limited storage and bandwidth. But that will be okay for starting point. The only problem is because 'people never try'.
Hope it will help for newbie.