image upload from url with php oop -


i using code bellow upload images wp directory. tried modified code can download images directly url didnt have luck.

my code bellow:

<?php   class imguploader  {      var $exts = array( ".png", ".gif", ".png", ".jpg", ".jpeg" ); //all extensions allowed uploaded      var $maxsize = 9999999; //if set "0" (no quotes), there no limit      var $uploadtarget = "../wp-content/uploads/"; //make sure have '/' @ end      var $filename = ""; //this automatically set. not need worry      var $tmpname = ""; //this automatically set. not need worry       public function startupload()      {          $this->filename = $_files['uploaded']['name'];          $this->tmpname = $_files['uploaded']['tmp_name'];          if( !$this->iswritable() )          {              die( "sorry, must chmod upload target 777!" );          }          if( !$this->checkext() )          {              die( "sorry, can not upload filetype!" );          }          if( !$this->checksize() )          {              die( "sorry, file have attempted upload large!" );          }          if( $this->fileexists() )          {              die( "sorry, file exists on our servers!" );          }          if( $this->uploadit() )          {              echo "your file has been uploaded!<br><br>click <a href=\"" . $this->uploadtarget . time() . $this->filename . "\">here</a> view file!";          }          else          {              echo "sorry, file not uploaded unknown reason!";          }      }       public function uploadit()      {          return ( move_uploaded_file( $this->tmpname, $this->uploadtarget . time() . $this->filename ) ? true : false );      }       public function checksize()      {          return ( ( filesize( $this->tmpname ) > $this->maxsize ) ? false : true );      }       public function getext()      {          return strtolower( substr( $this->filename, strpos( $this->filename, "." ), strlen( $this->filename ) - 1 ) );      }       public function checkext()      {          return ( in_array( $this->getext(), $this->exts ) ? true : false );      }       public function iswritable()      {          return ( is_writable( $this->uploadtarget ) );      }       public function fileexists()      {          return ( file_exists( $this->uploadtarget . time() . $this->filename ) );      }  }  $img = new imguploader();     if( $_post['upload_file'] )  {      $img->startupload();  }  else  {      echo "<form method=\"post\" enctype=\"multipart/form-data\">          <p>              <label for=\"file\">select file upload:</label> <input type=\"file\" name=\"uploaded\" id=\"file\"><br>              <input type=\"submit\" name=\"upload_file\" value=\"upload!\">          <p>      </form>";  }  ?> 

i tried remove hole form , give $filename , $temp name image url doesnt work..

any idea?


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -