Adding image upload to html page (mysql backend) - php

Relatively new to web development here, but am trying to implement an image upload feature, the contents of which will be previewed to the person (administrator) uploading the image, and then stored in a database (and displayed to the end user on a different page).
I found a resource that uses a Imageshack API, and was a bit confused about what this is and how the person implemented the API to achieve the image upload. The code for this is here: http://www.sceditor.com/posts/how-to-upload-and-insert-an-image/
When I googled "Imageshack API," I kept running across something that said I need to request a key. What does this mean, and do I have to do it? Is this the easiest way to go about creating an image upload feature for my purposes?
Thank you all very much!

Imageshack API is for uploading image files to your account hosted at Imageshack.com. It seems that you want to upload image files to your own website and store such files on your own web servers (either in a cloud service such as AWS or your co-located/managed servers at some data centres). So, you probably do not want to use Imageshack.
As to how to upload image files using HTML & PHP, you may want to check out a short tutorial at:
www.w3schools.com/php/php_file_upload.asp
Also, by the way, storing image files into a database such as MySQL may not be a good idea -- image files should be stored as files. It is faster to access such image files on a web server than to access image contents stored in a database.

Related

How to get actual image from local path in PHP?

Disclaimer - Thanks for coming to this question! I would just like to say that I am an absolute beginner to PHP. Thanks!
Hi! I am working on a project (more specifically, a mobile-only App), in which I need to do the following things -
The user would give me his/her phone's path to the image, which is stored in his mobile.
Through API, I would send the path to my website's PHP file, and the PHP would capture the image from the path.
After displaying the image, the code would compress it with very high compression, and display the temporarily store the image.
Then I would upload the image to AWS S3 media database(maybe with PHP SDK?), and obtain the image's link.
So that's my plan, is it possible to do? And what are the steps to do the 2nd & 3rd step - i.e. catching the image from the phone's local path, and compressing it?
Any help is appreciated :)
Thanks a lot!
There is no possibility for you to remotely access any known mobile operating system's storage.
You want to upload a photo and process it - just do it! You can simply send the photo through your API to the PHP server, and it would receive it as it would receive any other file, e.g. from a website form.
Then, you use some tool like Imagick to edit the photo.
You return thumbnail to the user within the response of your API.
Yet simpler, isn't it?

posting dynamically to S3

Good afternoon!
I am trying to replace my host with an S3 Amazon service for images. The website currently uploads images successfully using an uploader without problems. So the questions I have are about migrating from host to S3. Trust me I have read the Amazon support blogs and searched the net. But I can find no single, concise, or easy to understand technical advice--just a lot of Amazon jargon.
For info, at the moment the uploader does the two things you would expect it to do well:
1) it uploads the files to a target folder to the specified (Define) UPLOAD path(no problem)
2) it generates the image POSTS ready for processing (no problem).
It is a nice uploader with lots of goodies for image management so I don't want to replace it- I simply want to build a bridge from the outputs it creates (as above) into Amazon S3?.
So my specific questions are can anyone tell in simple terms how to:-
..enable users to Upload the images posted by my uploader to Amazon S3
..Allow users to get images back via their own dynamic page views.
Many thanks in anticipation
ps for info this is the uploader but im not sure that is needed bearing in mind it works as expected and produced the outputs above and I cannot replace it at this stage of the development process.
https://github.com/blueimp/jQuery-File-Upload

How to upload multiple images to a server into a Django application?

I'm currently working on a Django application using AngularJS for the frontend part.
I want for the moment to upload some images on the server and get as callback a list with the paths of the uploaded files. I want to send afterwards to the API (I am using Tastypie framework) as a POST request the callback and insert it into the database in a specific field. My issue is that I don't know how to approach the images upload (I should use PHP?) part and most important how to receive the callback? I hope that I explain clear enough. :D
Documentation for uploading files in django: https://docs.djangoproject.com/en/dev/topics/http/file-uploads/
HTML only allows to upload one file per upload-controller. To upload multiple files either the user can create a zip file (or similar), upload that and on the server side you extract it into multiple files. Or you have to use a flash component. There are lots of these available, for example http://developer.yahoo.com/yui/uploader/

Saving uploaded media content

I'm making my own website using html and php, and a database using mysql on localhost on a easyPHP server. Users can make an account and upload videos on the site.
I'm wondering if it would be possible when they upload the file, it would upload the file to youtube and I can just save that link in my database. Then on the content page I could just use that link to show the video in an embedded player.
If that's not possible, what would be the best way to save the content in a folder on my PC?
Thanks
Yes, Youtube allows uploading video files directly to Youtube's servers, bypassing your server.
This page documents it pretty well: https://developers.google.com/youtube/2.0/developers_guide_protocol_browser_based_uploading

How to upload to a static content server with php?

I am launching a web application soon that will be serving a fair amount of images so I'd like to have a main web server and a static content server and possibly a separate database server later on.
I'd like the user to:
login and be able to upload a photo
the photo is renamed a randrom string
the photo is processed into a thumbnail
the photo and thumbnail are stored into a filesystem on the static server.
the photo and thumbnail's directory and filename are stored in a mysql database
The problem is I don't know how to have the user instantly upload an image to a separate server.
I thought about using amazon s3, but you can't edit filenames before posting them. (through POST, I'd rather not use the REST api)
I could also use php's ftp function to upload to a separate server, but I'd like to dynamically create folders based on the properties of the image (so I don't have all the images in one big folder obviously), but I don't know how this would work if I used ftp...
Or I could save them locally and use a CDN, I'm not too familiar with CDN's so I don't know if using them this way would be appropriate or cost-effective.
What are my options here? I'd like the images to be available instantly (no cron jobs/queues)
Thanks.
You can create directories over FTP with PHP, so that should not be a showstopper.
I thought about using amazon s3, but you can't edit filenames before posting them. (through POST, I'd rather not use the REST api)
If you let your PHP server do the uploading to S3 via POST, you can name the files whatever you want. You should do that anyway, letting your users upload to S3 directly, without your PHP code inbetween, sounds like bad for security to me.

Categories