Hi, I was trying to save a qr code into a directory path (…/QR_Code/image.png) which will later will be saved on my database.
<?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);
// declare image path
$image_path='c:\\domains\\mywebsite.com\\wwwroot\\PDRM\\QR_Code\\image.png';
// now save a copy of the new image to the cache directory
imagePNG($img, $image_path);
print '<center><img src=http://mywebsite.com/PDRM/image.png><br>';
//print('<font color=#30afd8><H2>Saved QR Code.</H2></font>');
imagedestroy($img);
}
?>
But when I check at my database the value is still null. I’m not very familiar with window server. Before this when I was working on Apache server, the image path i used was /var/www and it saved the image perfectly on the database. Maybe the image path is incorrect? Any thoughts would be helpful. Thanks!
Windows might be interpreting anything after the .com to be a file extension so maybe it’s seeing it as a file called mywebsite with everything that follows that bit as a file extension
$img = imagecreatefromstring($rawdata);
// declare image path
$image_path='c:\\domains\\mywebsite.com\\wwwroot\\PDRM\\QR_Code\\image.png';
// now save a copy of the new image to the cache directory
imagePNG($img, $image_path);
I want it to save the image inside QR_Code directory and write into my database with field named ‘imagePNG’. But nothing happened. And the imagePNG still contain NULL value.
Previously, I’ve been using the same codes on linux with this image path:
The image.png was written at both QR Code directory and into imagePNG field. So i’m thinking this must be a wrong way/wrong directory to write the image( c:\domains\mywebsite.com\wwwroot\PDRM\QR_Code\image.png’; ). Or is it not?
Warning: imagepng() [function.imagepng]: Unable to open 'http://localhost/PDRM/QR_Code/image.png' for writing: Invalid argument in C:\\Domains\\datacalibre.com\\wwwroot\\PDRM\\updated5.php on line 1088