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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:26:57+00:00 2026-06-11T13:26:57+00:00

I have the follow code: $image = imagecreatefromstring(file_get_contents(‘http://externaldomain.com/image.png’)); And want to make a curl

  • 0

I have the follow code:

$image = imagecreatefromstring(file_get_contents('http://externaldomain.com/image.png'));

And want to make a curl request:

$files = array();
$files[] = '@' . $image['tmp_name'] . ';filename=' . $image['name'] . ';type=' . $image['type'];

$ch = curl_init('index.php?route=upload');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $files);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($ch);

The main problem is, how to get the file name and extension from $image variable?

I can replace $image['tmp_name'] with tempnam(), but other things?

Have another way to do?

  • 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-11T13:26:59+00:00Added an answer on June 11, 2026 at 1:26 pm

    imagecreatefromstring returns a GD handle. There is no tmp_name, name, OR type associated with it. You’re trying to treat that GD handle as if it was the result of a standard POST-based $_FILES data structure.

    a GD handle cannot be passed to curl for upload, because it’s not really an image, and won’t be until you use imagejpeg/imagepng/imagewhatever to save it out to a file, which you can then point curl at, e.g.

    $image = imagecreatefromstring(...);
    imagejpeg($image, 'tempfile.jpg');
    
    $files[] = '@tempfile.jpg;filename=tempfile.jpg;type=image/jpeg';
    
    curl...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, http://www.site.com/check.php?id=1); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
I have an issue about http://code.google.com/p/django-simple-captcha/ project. I've follow the procedure to install captcha,
in cake php 1.3 in view ctp i have follow code: $url = 'http://example.com/exmp/explus/books/view/'.$book['Book']['id'];
This is the code i am using when i have image.src = /local/directory/image.png works
Having trouble linking the Stomp.framework into an iPhone SDK application. http://code.google.com/p/stompframework/ I follow the
I have this code for make a image search trough Google Image API: $(document).ready(function(){
I have follow a sample code, for create a simple image view zoom/pan page,
I have this follow code in my javascript. I call this function when the
i have the follow code: searchResults.SearchResultCollection.Add( new SearchResult() { Header = HttpUtility.HtmlDecode( htmlDocument.DocumentNode .SelectSingleNode(initialXPath
So... is strange, I have the follow code in my Window control for setting

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.