Ok, like this: (Iβm changing this post content for the third time to better explain)
My site is an Image Hosting website, which means that a user can upload it to my site and get a direct link to their uploaded image.
I need some kind of API / way to communicate from my site with my users. I want users registered on my website to be able to DOWNLOAD IMAGES from their website to Image Host without having to leave their own website (AJAX, iFrame, cURL, JSON, whatever it takes).
The request to my site should contain the &request=api parameter so that the user receives the plain text returned from my upload.PHP script. Thus, I think that I am providing an easier way to capture data / output from my site.
So, basically AFTER the POST / FILES request from the user's site to my image host , they get the link (s) from my script loading processing, which they should extract and then use for their needs.
My question is: My registered user sends the file to my server WITHOUT reloading the page and returns the URLs of this image. How to do it?
What I tried:
All my attempts were blockages without continuing.
First I added two new columns to two different tables. My users table received an api_key column, which is intended to store the API key, if the user actually signs it. Another is_api column was added to the table where I store image information, only registered users have their images stored in the database. With this new column (which was of type TINYINT ), I wanted to verify that the image coming from the user was (or was not) added / added via the API.
A user sends a request to my image host with these parameters: upload.php?submit=true&action=upload&request=api&key=_SOME_API_KEY_ . I take the API key and check to whom it belongs β Get the user ID based on this key β I save the image on my server β I store image information in my database (now there is a user ID) β I echo outside the URL.
My failures here were:
- I cannot send ANYTHING from a third-party site to my Image Host asynchronously
- I could not get anything back to my third-party website.
Why are these failures? Because I have no idea how to achieve these two most important steps.
One of my ideas to stop trying to send $_FILES[] to my image host was trying to send IMAGE STRING via POST to my server and create the image there myself. I also could not do this, it was just the thought of a guy who managed to think.
So, here it is: My big problem without a solution from me.
If you need more information to help me more easily, please ask.
Thanks.
Update
If I could get the file somehow (asynchronously), I would register it in the database with the is_api field with a value of 1 to mark it as put via the API (external). That way I could create a new file called viewer.php , maybe it will take some parameters as well as viewer.php?request=api&key=_API_KEY_ , and it will return a JSON page with a link to the last image so that the external api user. Retrieving the page via JSON on a third-party website would be quite simple. Thus, with this method, I just need to somehow get the image in my Image Host , and the extracted part will not be too complicated. So, how do I send IMAGE STRING to my image host via POST ?
If this new idea of ββmine is used, please let me know.