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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:42:56+00:00 2026-06-09T12:42:56+00:00

I’m trying to make a little script to rehost pictures on the web on

  • 0

I’m trying to make a little script to rehost pictures on the web on imgur.

This is called Image Sideloading and you only need to point the browser to http://api.imgur.com/2/upload?url= + Picture’s Url

It doesn’t return any XML or JSON response so I can’t parse it to get the img URL.

But I think I found a way to do this but can’t get it to work properly. Here’s the code I’m using.

$(document).ready(function() {
    $("#button").click(function() {
        str = $("input").val().toString();
        link = "http://api.imgur.com/2/upload?url=" + str;
        var xhr = new XMLHttpRequest();
        xhr.open("GET", link);
        xhr.send();
        var headers = xhr.getAllResponseHeaders().toLowerCase;
        alert(headers);

    });

});

And looking at Google Chrome’s console these are the results generated after the script runs.

I am not allowed to post images yet so here’s a link to the results: https://i.stack.imgur.com/zAKC2.png

I need to somehow access that 4th response header because even though this method doesn’t return any parsable XML or JSON response that link is the uploaded img’s URL which is all I need.

So is there a way to access that info? Why is it cancelled?

Thanks everyone!

  • 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-09T12:42:58+00:00Added an answer on June 9, 2026 at 12:42 pm

    Well, the API must return something, else it is useless.

    Actually, http://api.imgur.com/examples advises you to do something like:

    var xhr = new XMLHttpRequest();
    xhr.open("GET", link);
    xhr.onload = function() {
        var url = JSON.parse(xhr.responseText).upload.links.imgur_page;
        alert(url);
    }
    xhr.send();
    

    Edit. OK, I got it. Normally, the above code should work, but I think imgur is facing a problem. I will report the bug.

    While the bug is still there, here is a dirty solution to serve your needs:

    var xhr = new XMLHttpRequest();
    xhr.open("GET", link);
    xhr.onload = function() {
        html = xhr.responseText;
        alert(html.substr(html.indexOf('http://i.imgur.com/') + 19, 5));
    }
    xhr.send();
    

    You code wasn’t working because you weren’t waiting for the answer. You have to catch it through a callback function.

    Edit. The above code only works locally. As you’re using jQuery, let me introduce the shortcut $.post:

    $(document).ready(function() {
        $("#button").click(function() {
            $.post('http://api.imgur.com/2/upload.json', {
                key: 'ec575de603b936e54c2b4a9f232d537e',
                image: $("input").val().toString()
            }, function(data) {
                alert(data.upload.image.hash);
            });
        });
    });​
    

    http://jsfiddle.net/Le_Sphinx/rEfdS/

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
this is what i have right now Drawing an RSS feed into the php,

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.