Hi,
When you have something that is not working or wrong, the first thing to do is look at the error log ... but to do so would require that errors are not masked and remove the "@" of function calls.
A second thing is to thoroughly test the return value of a function.
PHP documentation for readfile said:
Returns the number of bytes read from the file. If an error occurs, FALSE is returned and unless the function was called as @readfile(), an error message is printed.
You test:
If ($wasdownloaded)
that is to say, you verify that the result is true, but it is not what to do, you have to test if the result is false.
if ($wasdownloaded === false)
echo "error";
else
echo "no error";
If the file exists but is empty, this will not be considered true, but it is not false either because there will be no errors.
------------------------------------------------------------------------------------------------------------
Wampserver 3.2.9 32 bit - Apache 2.4.53 - PHP 8.1.5…5.6.40 - MySQL 5.7.38 - MariaDB 10.5.13/10.6.5
Wampserver 3.2.9 64 bit - Apache 2.4.53 - PHP 8.1.5…5.6.40 - MySQL 5.7.38/8.0.29 - MariaDB 10.5.15/10.7.3
PhPMyadmin 5.1.3 - MysqlDumper 1.24.5 on W10 and W7 Pro 64 bit
Documentation Apache -
Documentation PHP -
Documentation MySQL -
Wampserver install files & addons« Ce n'est pas parce qu'ils sont nombreux à avoir tort, qu'ils ont forcément raison. Coluche »
« It's not because they are many to be wrong, they are necessarily right. Coluche »