Jump to content

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


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.

Edited by rose8383
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.