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 6655823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:34:04+00:00 2026-05-26T01:34:04+00:00

I am using PHP to create an image file on my server. Now I

  • 0

I am using PHP to create an image file on my server. Now I need to upload this through a POST to a server of a 3rd party. Easiest would be to use a server side cURL script to accomplish that but I have to do it through my client, because it needs to be uploaded in the context of the active session between the client and the 3rd party server. The question is how can I achieve this easiest?

  1. Is it possible to use say an HTML form or AJAX call and upload the image from by giving it the URL? The thing is that the 3rd party back end does not accept URLs, it needs to be represented as if it was an upload through a web form…

  2. If that is not possible, I was thinking to use an AJAX call to download the image and save the contents to a variable. Then create a form that uploads the contents of the image as if a local file was selected in the form. How should I accomplish that?

When I upload a file through a web form and look at the HTTP headers being sent I see something like this:

------WebKitFormBoundary3ygta7rqeBm1krBO
Content-Disposition: form-data; name="MAX_FILE_SIZE"

10000000
------WebKitFormBoundary3ygta7rqeBm1krBO
Content-Disposition: form-data; name="uploadedfile"; filename="test.jpg"
Content-Type: image/jpeg


------WebKitFormBoundary3ygta7rqeBm1krBO--

Should I create a string like in this format and then submit that as data through an AJAX call? Where do I put the actual binary image data? I guess the Chrome developer tools suppress that data…

Thanks for any pointers.

  • 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-05-26T01:34:04+00:00Added an answer on May 26, 2026 at 1:34 am

    I think the easiest seems to be what you said, upload it to the 3rd party through your server. Is there a way for you to get whatever from the user’s session through your PHP script?

    Otherwise, you can try sending back to the client (perhaps via AJAX) the image in some encoded format, like base64, after your server has generate it, then build a custom XHR to send the file to the 3rd party… here’s a sample:

    var boundary = this.generateBoundary();
    var xhr = new XMLHttpRequest;
    
    xhr.open("POST", this.form.action, true);
    xhr.onreadystatechange = function() {
        if (xhr.readyState === 4) {
            alert(xhr.responseText);
        }
    };
    var contentType = "multipart/form-data; boundary=" + boundary;
    xhr.setRequestHeader("Content-Type", contentType);
    
    for (var header in this.headers) {
        xhr.setRequestHeader(header, headers[header]);
    }
    
    // here's our data variable that we talked about earlier
    var data = this.buildMessage(this.elements, boundary);
    
    // finally send the request as binary data
    xhr.sendAsBinary(data);
    

    See more info here (below the “The XMLHttpRequest object” section):
    http://igstan.ro/posts/2009-01-11-ajax-file-upload-with-pure-javascript.html

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

Sidebar

Related Questions

I need to create a web application using php, I had many users having
I want to create a cookie using php,an also i need to read it
How does one create Dynamic CSS and JavaScript On-The-Fly (using PHP). This needs to
Ive been working on create a file upload form using PHPmailer to send as
I am trying to create a dynamic image of my friends using PHP's GD
Simply this the code for PHP page the uses AJAX to upload file, but
I am creating an image dynamically using php. The image is being created if
I want to create sub-domains using PHP on the fly. Suppose a user registers
I am using PDO with PHP to create a new database and then a
I want to create a command line program using PHP. How do I design

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.