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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:00:35+00:00 2026-05-27T04:00:35+00:00

I came across http://api.imgur.com and thought that would be a usefull tool to use

  • 0

I came across http://api.imgur.com and thought that would be a usefull tool to use on my website. I then noticed that StackOwerflow uses it too, so it must be good )))
Although I’m struggling when I try to implement it. I took a look at
http://api.imgur.com/examples the PHP section, but it didn’t help me much.

What I’m interested in is includin imgur api on my website so users can upload their images. I would than need to store img url/path so I can display it on a website.

e.g. have a form that will allow users to upload photo, then store url/path of the uploaded image in a database (VARCHAR).

Has anyone had a success with this system and could help me understand how to implement it like StackOwerflow uses it (only store image url in database not post).

Code I tried:

 <form enctype="multipart/form-data" method="post" action="upload_img.php">
    Choose your file here:
    <input name="uploaded_file" type="file"/>
    <input type="submit" value="Upload It"/>
    </form>

upload_img.php

<?
    $filename = "image.jpg";
    $handle = fopen($filename, "r");
    $data = fread($handle, filesize($filename));

    // $data is file data
    $pvars   = array('image' => base64_encode($data), 'key' => IMGUR_API_KEY);
    $timeout = 30;
    $curl    = curl_init();

    curl_setopt($curl, CURLOPT_URL, 'http://api.imgur.com/2/upload.xml');
    curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $pvars);

    $xml = curl_exec($curl);

    curl_close ($curl);
?>
  • 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-27T04:00:36+00:00Added an answer on May 27, 2026 at 4:00 am

    I see that you have copy and pasted the example from the imgur API site, which gives the example of a filename which is contained within $filename. You need to point this variable at the file that PHP has uploaded.

    Modify the $filename part of your script:

    $filename = $_FILES['uploaded_file']['tmp_name'];
    

    Source: POST method file uploading

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

Sidebar

Related Questions

I came across this code http://support.microsoft.com/kb/320348 which made me wonder what would be the
I came across Drew Baker's froogaloop API example page: http://labs.funkhausdesign.com/examples/vimeo/froogaloop2-api-basics.html I view and copy
I recently came across http://chromeexperiments.com/ . I found a couple of projects there that
I came across the following http://ckeditor.com/demo , and was wondering if anyone had a
Just came across this by Chris Coyier - http://css-tricks.com/examples/CSSTabs/ Can anyone explain me, how
I came across an article about Car remote entry system at http://auto.howstuffworks.com/remote-entry2.htm In the
I came across 2 different modules for porting Django to App Engine: http://code.google.com/p/app-engine-patch/ http://code.google.com/p/google-app-engine-django/
I'm trying to integrate Amazon Product API into my website and came across several
I came across http://www.damnlag.com/ yesterday and I have no idea how they have managed
i came across this http://www.brighthub.com/mobile/google-android/articles/48845.aspx i understand i can create a view. But i

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.