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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:12:51+00:00 2026-06-07T16:12:51+00:00

I have a simple php code which loads an external XML file and loads

  • 0

I have a simple php code which loads an external XML file and loads the pictures URL’s into my database.

Then I take the URL’s and display them on my site.

The problem is that I end up loading pictures from other websites on my site, which affect loading time – loading 20 pictures per page now.

So I am thinking, Is there a way to store the image completely into my database, instead of just the URL?

Here is the code:

    $myfeed = 'xmlfeed.xml';

    $myfeed_xml = simplexml_load_file($myfeed);

    foreach($myfeed_xml->info as $myinfo){
        $pic0 = $myinfo->picture_url[0];
        $pic1 = $myinfo->picture_url[1];
        $pic2 = $myinfo->picture_url[2];
        $pic3 = $myinfo->picture_url[3];
        $pic4 = $myinfo->picture_url[4];  

        if($pic0 != ''){

            mysql_query("INSERT INTO ".$table." (pic0, pic1, pic2, pic3, pic4) VALUES ('$pic0', '$pic1', '$pic2', '$pic3', '$pic4')", $dbh);

        }
    }  

Thank you!

  • 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-07T16:12:53+00:00Added an answer on June 7, 2026 at 4:12 pm

    Why not download them all on your server, and update the DB with the links from your server? As long as copyright policie(s) are okay with it…

    // do your DB fetching here
    
    //loop through all current db links
    foreach($sqlResult as $result)
    {
    
    // build up file path to store newly downloaded image
    $fPath="someFolder/pictures/";
    
    // get/generate a name for the pics (I'll just use a radom number here, but you should avoid doing so if you are working with lots of urls as dups may happen)
    $iName=mt_rand();
    
    //join path and url together
    $pAndURL=$fPath.$iName;
    
    // get and put data
    file_put_contents($pAndURL,file_get_contents($result['collumnWhereURLIsStored']);
    
    //now update your DB with the new link ($pAndURL)
    
    }//end of foreach
    

    So what the code above does is simply goes through all the 3rd party links in your DB and downloads their content (images) to your server. Then you can simply update the DB with your own link to the specific image. Simple. But as I previously mentioned, check copyright licenses first as I’m sure you don’t want to be getting into trouble now, hm?

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

Sidebar

Related Questions

I have written simple code to get content from xml file to php. $xml
I have the following PHP code doing a very simple select into a table.
I have a simple script of code that reads a PHP file and when
I have a really simple PHP script here,which simply loads several libraries (6 or
i have this simple code to load data from other php page using get
I have written a simple code in page test_cookie.php to work with cookies. if(isset($_GET['data']))
My problem is the following: I have a real simple PHP file called writeSettings2.php
I have done a simple GoogleMap which responses to script.php?q=canada and shows a map.
I use .htaccess Mod Rewrite to send the URL to index.php, which then parses
I have this very simple CODE, which should generate me HTML, but all 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.