• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Upload image from URL

#1
[eluser]cyberjunkie[/eluser]
Is it possible to use the File Uploading Class to upload images from a URL? I'm trying to use a callback but it expects a file to be selected from the computer.

In callback


Code:
function _url_upload($str) //$str is text input value, a URL string
{
   // Failed attempt, trying to load file from URL
   $img = file_get_contents($str);
   $_FILES['userfile'] = $img;
  
  
   $config['upload_path'] = "./uploads";
   $config['allowed_types'] = 'jpg|png';
   $config['encrypt_name'] = TRUE;
   $config['overwrite'] = FALSE;
   $config['max_size'] = '800'; //in KB
  
   $this->load->library('upload', $config);
  
   if (! $this->upload->do_upload())
   {
    //set file errors
    $this->form_validation->set_message('_file_validation', $this->upload->display_errors('', ''));
    return FALSE;
   }
   else
   {  
    return TRUE;
   }
}


Messages In This Thread
Upload image from URL - by El Forum - 07-13-2012, 07:57 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.