<? Php Function GrabImage ($ url, $ filename = ""){ If ($ url = "") return false; If ($ filename = ""){ $ Ext = strrchr ($ url ,"."); If ($ ext! = ". Gif" & $ ext! = ". Jpg") return false; $ Filename = date ("dMYHis"). $ ext; } Ob_start (); Readfile ($ url ); $ Img = ob_get_contents (); Ob_end_clean (); $ Size = strlen ($ img ); $ Fp2 = @ fopen ($ filename, ""); Fwrite ($ fp2, $ img ); Fclose ($ fp2 ); Return $ filename; } Function gethttpimage ($ url ){ If (! Empty ($ url )){ $ Filename = uniqid (). strrchr ($ url ,"."); Echo $ filename; $ Get_file = @ file_get_contents ($ url ); If ($ get_file ){ $ Fp = @ fopen ($ filename, "w "); @ Fwrite ($ fp, $ get_file ); @ Fclose ($ fp ); } Return $ imgUrl; } Else { Return false; } } // $ Img = GrabImage ("http://www.jb51.net/images/logo.gif ",""); $ Img = gethttpimage ("http://www.jb51.net/images/logo.gif ",""); If ($ img) echo '<pre> </pre> '; Else echo "false "; ?> |