I've created a barcode using the PHP barcode plugin
HTML
<img src="barcode.php?codetype=Code128&size=50&text=123421321321321321" style="width:auto; height:auto;" alt="123456789"/>
How can I save this barcode image to my local drive hard drive?
I've created a barcode using the PHP barcode plugin
HTML
<img src="barcode.php?codetype=Code128&size=50&text=123421321321321321" style="width:auto; height:auto;" alt="123456789"/>
How can I save this barcode image to my local drive hard drive?
Try this get the content and save it to file
$barcode = file_get_contents('http://www.youdomain.com/barcode.php?codetype=Code128&size=50&text=123421321321321321');
//you can also use below function get more info on image
//$imgInfo = getimagesize($barcode);
//save the file to disk
file_put_contents('path_to_file/code.png', $barcode);
Use CURL
//You can also try it using CURL if above doesn't works
$ch = curl_init('http://www.youdomain.com/barcode.php?codetype=Code128&size=50&text=123421321321321321');
$fp = fopen('path_to_file/code.png', 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
Edit barcode.php
Now its very simple, as in file its simply returning header of image, right before you can add this line to save it on server
// Save the image to file.png
imagepng($image, "file.png"); // Your barcode will be saved here with name file.png
// Draw barcode to the screen
header ('Content-type: image/png');
imagepng($image);
imagedestroy($image);
Hope this helps