Jump to content

QR Code: saving the url to directory and then save the image on directory into database


rose8383

Recommended Posts

Hi,

 

1) I'm trying to save the url of a qr code into a directory (/home/inforlix/public_html/O/QR_Code/image.png).

 

2) Then i want the codes to write the image.png into my database under field name imagePNG

 

Here's my code:

 

<?php
//if ($_POST['submit']) { 
if ($_SESSION['MM_Username']) {


//$msg = $_REQUEST['msg'];
$msg= $row_RSU['QR_CODES'];
$url  = 'http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl='.$msg;


// initialize cURL settings
$ch = curl_init ($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);


// fetch raw data
$rawdata = curl_exec($ch);
curl_close($ch);


// convert it to a GD image and save
$img = imagecreatefromstring($rawdata);


    // now save a copy of the new image to the cache directory
imagePNG($img, '/home/inforlix/public_html/O/QR_Code/image.png'); 


print '<center><img src="http://inforlix.com/O/QR_Code/image.png"><br>';


//print('<font color=#30afd8><H2>Saved QR Code.</H2></font>');


    imagedestroy($img);
}   
?>
   

Unfortunately, the field imagePNG is still null in value. Please advise.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.