sebababi Posted August 31, 2009 Share Posted August 31, 2009 I’ve tried many combinations of these 2 codes This one is to upload to a folder, which is not really what I want. $url = "http://imageurl"; $filename = "filenametosave"; ob_start(); readfile($url); $img = ob_get_contents(); ob_end_clean(); $size = strlen($img); $fp = @fopen($filename, "ab"); fwrite($fp,$img); fclose($fp); this code is to upload pictures from a form as a BLOB, which is what I want, but instead of uploading from a form I want it from a URL, like $url = "http://imageurl"; $fileName = $_FILES['imagefile']['name']; $tmpName = $_FILES['imagefile']['tmp_name']; $fileSize = $_FILES['imagefile']['size']; $imtype = $_FILES['imagefile']['type']; @list(, , $imtype, ) = getimagesize($_FILES['imagefile']['tmp_name']); // Get image type. if ($imtype == 3) // cheking image type $imageextension="png"; // to use it later in HTTP headers elseif ($imtype == 2) $imageextension="jpeg"; elseif ($imtype == 1) $imageextension="gif"; else $msg = 'Error: unknown file format'; $fp = fopen($tmpName, 'r+'); $content = fread($fp, filesize($tmpName)); //reads $fp, to end of file length $instr = fopen("latest.img","rb"); $image = addslashes(fread($instr,filesize("latest.img"))); Could someone help me out? Thanks, Sebastian Quote Link to comment Share on other sites More sharing options...
ReKoNiZe Posted September 1, 2009 Share Posted September 1, 2009 Please use code tags, your code makes my eyes bleed $fileName = $_FILES['imagefile']['name']; $tmpName = $_FILES['imagefile']['tmp_name']; $fileSize = $_FILES['imagefile']['size']; $imtype = $_FILES['imagefile']['type']; @list(, , $imtype, ) = getimagesize($_FILES['imagefile']['tmp_name']); // Get image type. if ($imtype == 3) // cheking image type $imageextension="png"; // to use it later in HTTP headers elseif ($imtype == 2) $imageextension="jpeg"; elseif ($imtype == 1) $imageextension="gif"; else $msg = 'Error: unknown file format'; $fp = fopen($tmpName, 'r+'); $content = fread($fp, filesize($tmpName)); //reads $fp, to end of file length $instr = fopen("latest.img","rb"); $image = addslashes(fread($instr,filesize("latest.img"))); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.