Closed. This question needs
details or clarity. It is not currently accepting answers.
Answer
Solution:
Assuming that the $codeimg is the data you use to generate the QRcode.
- Please create the "temp" folder by yourself thru say FTP/sFTP (please do not rely on the PHP to create it for you because it may be forbidden by your parent directory permission settings).
- Please set the temp folder permission to be
writable
Then change
<?php
include "./phpqrcode/qrlib.php";
$PNG_TEMP_DIR = 'temp/';
if (!file_exists($PNG_TEMP_DIR))
mkdir($PNG_TEMP_DIR);
$filename = $PNG_TEMP_DIR . 'test.png';
if (isset($_POST["generate"])) {
$filename = $PNG_TEMP_DIR . ($_POST['codeimg']) . '.png';
QRcode::png($codeimg, $filename);
}
to
<?php
include "./phpqrcode/qrlib.php";
include("./phpqrcode/qrconfig.php");
// $PNG_TEMP_DIR = 'temp/';
// if (!file_exists($PNG_TEMP_DIR))
// mkdir($PNG_TEMP_DIR);
$filename = './temp/test.png';
if (isset($_POST["generate"])) {
// $filename = $PNG_TEMP_DIR . ($_POST['codeimg']) . '.png';
QRcode::png($codeimg, $filename);
}
The above will save a QRcode file (in PNG format) known as "test.png" under the subdirectory temp
If you want to save the file using other filename then change the code for the $filename part.
[Additional Information]
You may test the above thru the following sandbox link
(fully working)
http://www.createchhk.com/SOanswers/sube/ptest.php
<form method=post action="testSO9Nov2022.php">
Text: <input name=codeimg><br><br>
<input type=submit name=generate>
</form>
which will trigger the script testSO9Nov2022.php as follows:
<?php
include "./phpqrcode/qrlib.php";
include("./phpqrcode/qrconfig.php");
$filename = './temp/test.png';
if (isset($_POST["generate"])) {
QRcode::png($codeimg, $filename);
}
?>
Generated QRCODE is:
<br><br>
<img src=./temp/test.png>
Source