Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9291433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:38:43+00:00 2026-06-18T20:38:43+00:00

Okay here it is: (I am changing this post’s content for the third time

  • 0

Okay here it is: (I am changing this post’s content for the third time to explain better)

My website is an Image Hosting website, meaning the user can upload to my website and receive a direct link to his/her uploaded image.

I need some sort of API/way to communicate from my site with my users. I want users that are registered to my website be able to UPLOAD IMAGES from their website to my Image Host without them having to leave their own website (AJAX, iFrame, cURL, JSON, whatever it takes).

The request to my website should include a &request=api paramater so the user gets plain text returned from my upload.php script. This way I think I ensure an easier way of grabbing data/output from my site.

So, basically, AFTER a POST/FILES request from the user’s site to my Image Host, they receive link(s) from my upload processing script, which they need to retrieve and then use for their own needs.

My question is: My registered user sends a file to my server WITHOUT reloading the page and gets back the URL(s) to that image. How do I do this?

What I have tried:

All my tries were blockages with no continuing.

First, I added two new columns to two different tables. My users table received an api_key column, which was intended to store an API key if the user actually signs up for it. The other column is_api 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 type TINYINT) I wanted to check that the image coming from the user was (or was not) added/uploaded via the API.

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 whom it belongs to -> Retrieve an user id based on that key -> I store the image to my server -> I store image information in my database (have an user id now) -> I echo out the URL.

My failures here were:

  • I couldn’t send ANYTHING from the 3rd party website to my Image Host asynchronously
  • I couldn’t receive anything back to my 3rd party website.

Why 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 an IMAGE STRING via POST to my server and create the image there myself. I couldn’t do this either, it was just a thought of a guy who had time to think.

So, this is it: My big problem with no solution from myself.
If you need more information in order to help me out more easily, please ask.

Thank you.

Update

If I just could receive the file somehow (asynchronously) I’d register it in the database with the is_api field with a value of 1, to mark it as put via the API (external). This way, I could create a a new file named viewer.php maybe and it would accept some parameters too like viewer.php?request=api&key=_API_KEY_ and it would return a JSON page with the link to the latest image by that external api user. Retrieving the page via JSON by the 3rd party website would be quite easy. So, with this method, I basically just need to receive the image somehow in my Image Host and the retrieving part wouldn’t be too hard. So how would I send an IMAGE STRING to my Image Host via POST?

If this new idea of mine is exploitable, please let me know.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T20:38:44+00:00Added an answer on June 18, 2026 at 8:38 pm

    I am providing a script like this one to my users as a bridge to my website:

    <?php 
    $api_key = 'n8N9v0g9e7b1h0H4A7s2t6q5K8f07B6E4a5p2k4D6L2T1G4Y7I3z5Q5';
    $uses_ajax = false;
    $imgit = array('error' => true);
    
    if (isset($_POST['imgit_request']))
    {
        if ($_POST['imgit_request'] == 'upload')
        {
            $post_data = array(
                'submit'  => 'true',
                'action'  => 'upload',
                'request' => 'api',
                'api_key' => $api_key,
                'imagestr' => chunk_split(base64_encode(file_get_contents($_FILES['images']['tmp_name']))),
                'imagemime' => $_FILES['images']['type'],
                'imagename' => $_FILES['images']['name'],
                'imagesize' => $_FILES['images']['size'],
            );  
        }
        else if ($_POST['imgit_request'] == 'remote')
        {
            $post_data = array(
                'submit'  => 'true',
                'action'  => 'remote',
                'request' => 'api',
                'api_key' => $api_key,
                'links'   => $_POST['links'],
            );  
        }
    
        $curl = curl_init();
        curl_setopt_array($curl, array(
            CURLOPT_RETURNTRANSFER => 1,
            CURLOPT_URL => 'http://dugi/imgitv3/upload.php',
            CURLOPT_CONNECTTIMEOUT => 5,
            CURLOPT_POST => 1,
            CURLOPT_POSTFIELDS => $post_data,
        ));
    
        $resp = curl_exec($curl);
        curl_close($curl);
    
        if (strpos($resp, 'http://') !== false)
        {
            $imgit = array(
                'direct' => $resp,
                'thumb' => str_replace('/i/', '/t/', $resp),
                'error' => false,
            );
    
            if ($uses_ajax)
            {
                echo $imgit['direct'];  
            }
        }
        if (strpos($resp, 'http://') === false)
        {
            $imgit = array(
                'error' => $resp,
            );  
        }
    }
    ?>
    

    Then I do the rest of the processing in my website based on the information I receive. I will be updating this answer once I finish the complete API CP on my website, where the webmaster who is using the API can see what images have been uploaded via his website to my Image Host. From the script above, you can see an API key – it’s unique for every user, the one above is just a sample.

    For asynchronous I made it work by telling the users to use the jQuery Form plugin. It’s a very handy plugin for submitting forms and I show the user how they would do it.

    Thanks for everyone who tried to help me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay so here is the deal. As the question states, I'm trying to POST
Okay this is definitely a n00b question but here goes. The way I understand
Okay here's the situation.... I'm working on a my business website. There will be
Okay, so I'm pretty frustrated here. This piece of code here is just a
okay here is the example: data = ['This', 'is', 'a', 'test', 'of', 'the', 'list']
Sorry for the title couldn't come with a better one... Okay here's is my
Okay here is the case. I have a image with a fixed width and
Okay here's my situation. I have the following branches development development-kirby (270 commits ahead
Okay here is what I'm trying to do: I have a model object that
Okay so here's, the scenario I have a thumbnail that contains an artists profile

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.