Cool. Managed to get it done $org_pic = htmlentities(stripslashes(trim(strip_tags($_POST['org_pic'])))); $org_pic = bin2hex(file_get_contents($org_pic));
and the post value is the google image URL that I've injected into the value of the radio button. Thanks! On Tuesday, November 27, 2012 2:15:39 PM UTC+13, rusdvl wrote: > > I do have it set, but the issue is that function just pulls the top 3 > searches and refreshes the src of the img tags in the HTML; then in the > HTML the users selects via a radio button which image out of the three they > want to use. So I need to grab the image they have selected to use and then > send it as a hex value to the other program. > > On Tuesday, November 27, 2012 2:07:08 PM UTC+13, David Neilsen wrote: >> >> Assuming you have allow_url_fopen set to ture, you can still use >> bin2hex(file_get_contents(getGoogleImg(...))) >> >> >> http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen >> http://php.net/manual/en/function.bin2hex.php >> http://php.net/manual/en/function.file-get-contents.php >> >> David Neilsen | 07 834 3366 | PANmedia ® >> >> >> On Tue, Nov 27, 2012 at 1:32 PM, rusdvl <[email protected]> wrote: >> >>> Thanks. That worked great. >>> >>> Now another question on the same topic... I have a script that pulls the >>> top 3 Google image search results based on what a user enters in a field. I >>> also need to grab the selected image and convert it into a hex value... >>> since I only pull the src from google... is there a way to do that? >>> >>> Code below: >>> >>> HTML: >>> >>> <label for="logo0"> >>> <img src="images/logos/unicorn.png" alt="Logo - Unicorn" /> >>> </label> >>> <input type="radio" name="org_pic" value="option1" id="logo0" checked /> >>> >>> <label for="logo1"> >>> <img src="images/logos/green_male.png" alt="Logo - Green male" /> >>> </label> >>> <input type="radio" name="org_pic" value="option2" id="logo1" /> >>> >>> <label for="logo2"> >>> <img src="images/logos/orange_female.png" alt="Logo - Orange female" >>> /> >>> </label> >>> <input type="radio" name="org_pic" value="option3" id="logo2" /> >>> >>> <input id="fileupload_org" type="file" name="fileupload" >>> class="fileupload" onchange="PreviewImg(this)" /><br /> >>> <input type="radio" name="org_pic" value="option4" class="upload_option" >>> /> >>> >>> <input type="submit" name="submit" value="Submit" /> >>> >>> >>> >>> PHP: >>> >>> function getGoogleImg($n, $k) >>> { >>> $url = " >>> http://www.google.com/search?num=##num##&hl=en&site=imghp&tbm=isch&source=hp&q=##query##+logo&oq=##query##+logo<http://www.google.com/search?num=#%23num%23%23&hl=en&site=imghp&tbm=isch&source=hp&q=%23%23query%23%23+logo&oq=%23%23query%23%23+logo> >>> "; >>> $str = array('##num##', '##query##'); >>> $rep = array(urlencode($n),urlencode($k)); >>> $web_page = file_get_contents(str_replace($str, $rep, $url)); >>> >>> preg_match_all('/<img [^>]*src=["|\']([^"|\']+)/i', $web_page, >>> $matches); >>> >>> $src = $matches[1]; >>> >>> return $src; >>> } >>> >>> if($_POST) >>> { >>> // set the keyword and number of results parameters >>> $k = $_POST['org_name']; >>> $n = 3; >>> >>> // call the function with set parameters >>> $res = getGoogleImg($n, $k); >>> >>> // echo the result in JSON format >>> echo str_replace('\/','/',json_encode($res)); >>> } >>> >>> >>> JavaScript: >>> >>> var delay = (function(){ >>> var timer = 0; >>> return function(callback, ms){ >>> clearTimeout (timer); >>> timer = setTimeout(callback, ms); >>> }; >>> })(); >>> >>> $(".org_name").change(function(){ >>> var searchbox = $(this).val(); >>> var dataString = 'org_name='+ searchbox; >>> delay(function(){ >>> >>> if(searchbox.length>1){ >>> $.ajax({ >>> type: "POST", >>> url: "assets/search.php", >>> data: dataString, >>> cache: false, >>> dataType: 'json', >>> success: function(server_response){ >>> $.each(server_response, function(key,value){ >>> $(".prev"+key).attr("src", value); >>> $("#logo"+key).val(value); >>> }); >>> } >>> }); >>> } return false; >>> }, 1000 ); >>> }); >>> >>> >>> Thanks again! >>> >>> >>> >>> On Tuesday, November 27, 2012 10:18:10 AM UTC+13, bogardan wrote: >>> >>>> file_get_contents($_FILES['**fileupload']['tmp_name']); >>>> >>>> >>>> >>>> On Tue, Nov 27, 2012 at 10:11 AM, rusdvl <[email protected]> wrote: >>>> >>>>> Do I actually need to save the file first? Or can I do something like >>>>> this... >>>>> >>>>> /* File type and other checks here */ >>>>> >>>>> $name = preg_replace("/[^A-Z0-9._-]/i"**, "_", >>>>> $_FILES["fileupload"]["name"])**; >>>>> $hex = bin2hex($name); >>>>> >>>>> Cheers >>>>> >>>>> >>>>> >>>>> On Tuesday, November 27, 2012 10:01:28 AM UTC+13, David Neilsen wrote: >>>>> >>>>>> bin2hex(file_get_contents($**ima**ge)); >>>>>> >>>>>> David Neilsen | 07 834 3366 | PANmedia ® >>>>>> >>>>>> >>>>>> On Tue, Nov 27, 2012 at 10:00 AM, Jay <[email protected]> wrote: >>>>>> >>>>>>> // read file >>>>>>> $fp = fopen($filename,"rb", 0); >>>>>>> $gambar = fread($fp,filesize($filename))****; >>>>>>> fclose($fp); >>>>>>> // base64 encode >>>>>>> $base64 = base64_encode($gambar); >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Tue, Nov 27, 2012 at 9:57 AM, rusdvl <[email protected]> wrote: >>>>>>> >>>>>>>> URL encoded. >>>>>>>> >>>>>>>> >>>>>>>> On Tuesday, November 27, 2012 9:56:13 AM UTC+13, Brett Taylor wrote: >>>>>>>> >>>>>>>>> Are they just asking for the file to be MIME or URL encoded or >>>>>>>>> something when you send it to them? I'd ask them for clarifications >>>>>>>>> on what >>>>>>>>> they are actually requesting. >>>>>>>>> >>>>>>>>> Brett >>>>>>>>> >>>>>>>>> On 27/11/2012, at 9:50 AM, rusdvl <[email protected]> wrote: >>>>>>>>> >>>>>>>>> Hi, >>>>>>>>> >>>>>>>>> I am currently building a form that is meant to send the contents >>>>>>>>> via an API to a flex based program. The developers on the other side >>>>>>>>> are >>>>>>>>> asking the uploaded images to be a hexadecimal string of the >>>>>>>>> image binary... I have been googling for a few hours, but obviously >>>>>>>>> my >>>>>>>>> google-fu is weak as I am unable to find any sample code or any >>>>>>>>> tutorials/examples on how to do so. >>>>>>>>> >>>>>>>>> Any help would be appreciated. >>>>>>>>> >>>>>>>>> Cheers! >>>>>>>>> >>>>>>>>> -- >>>>>>>>> NZ PHP Users Group: >>>>>>>>> http://groups.google.com/**group****/nzphpug<http://groups.google.com/group/nzphpug> >>>>>>>>> To post, send email to [email protected] >>>>>>>>> >>>>>>>>> To unsubscribe, send email to >>>>>>>>> nzphpug+u...@**googlegroups.com >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>> NZ PHP Users Group: >>>>>>>> http://groups.google.com/**group**/nzphpug<http://groups.google.com/group/nzphpug> >>>>>>>> To post, send email to [email protected] >>>>>>>> To unsubscribe, send email to >>>>>>>> nzphpug+u...@**googlegroups.com >>>>>>>> >>>>>>> >>>>>>> -- >>>>>>> NZ PHP Users Group: >>>>>>> http://groups.google.com/**group**/nzphpug<http://groups.google.com/group/nzphpug> >>>>>>> To post, send email to [email protected] >>>>>>> To unsubscribe, send email to >>>>>>> nzphpug+u...@**googlegroups.com >>>>>>> >>>>>> >>>>>> -- >>>>> NZ PHP Users Group: >>>>> http://groups.google.com/**group/nzphpug<http://groups.google.com/group/nzphpug> >>>>> To post, send email to [email protected] >>>>> To unsubscribe, send email to >>>>> nzphpug+u...@**googlegroups.com >>>>> >>>> >>>> -- >>> NZ PHP Users Group: http://groups.google.com/group/nzphpug >>> To post, send email to [email protected] >>> To unsubscribe, send email to >>> [email protected] >>> >> >> -- NZ PHP Users Group: http://groups.google.com/group/nzphpug To post, send email to [email protected] To unsubscribe, send email to [email protected]
