PHP - Warning: fopen(): Filename cannot be empty
-
Hi, I am facing an error of above mentioned subject, when I try to select the csv file of 3.9mb. Other way, when i select small file like 90kb then it works perfect.. See my following code:
if ($\_FILES\["file"\]\["error"\] > 0) { echo "Problem in file! " . "
";
echo "Error: " . $_FILES["file"]["error"] . "
";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "
";
echo "Type: " . $_FILES["file"]["type"] . "
";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB
";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
}$this\_filename = $\_FILES\["file"\]\["tmp\_name"\]; $csvfile = fopen($this\_filename, 'r'); // << error on this line
-
Hi, I am facing an error of above mentioned subject, when I try to select the csv file of 3.9mb. Other way, when i select small file like 90kb then it works perfect.. See my following code:
if ($\_FILES\["file"\]\["error"\] > 0) { echo "Problem in file! " . "
";
echo "Error: " . $_FILES["file"]["error"] . "
";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "
";
echo "Type: " . $_FILES["file"]["type"] . "
";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB
";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
}$this\_filename = $\_FILES\["file"\]\["tmp\_name"\]; $csvfile = fopen($this\_filename, 'r'); // << error on this line
The error message is quite clear: The content of
$_FILES["file"]["tmp_name"]
is empty. So check your code where that is set. If it is set for small files but not for large ones there must be some conditional statement in your code that does not set the name in some cases. -
The error message is quite clear: The content of
$_FILES["file"]["tmp_name"]
is empty. So check your code where that is set. If it is set for small files but not for large ones there must be some conditional statement in your code that does not set the name in some cases.I check it Thank you
-
Hi, I am facing an error of above mentioned subject, when I try to select the csv file of 3.9mb. Other way, when i select small file like 90kb then it works perfect.. See my following code:
if ($\_FILES\["file"\]\["error"\] > 0) { echo "Problem in file! " . "
";
echo "Error: " . $_FILES["file"]["error"] . "
";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "
";
echo "Type: " . $_FILES["file"]["type"] . "
";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB
";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
}$this\_filename = $\_FILES\["file"\]\["tmp\_name"\]; $csvfile = fopen($this\_filename, 'r'); // << error on this line
Also - consider that the large file does not yet exist on the server when because your code migh be doing the file-copy asynchronously. If this is the case, since it's not there yet, the name may not yet exist int the $_FILES["file"] array. You see how a large file may not be done whilst a small one will be transmitted very quickly. If other attempts at finding the problem fail, add a delay to your application between the upload and the access steps and see if that fixes things.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"As far as we know, our computer has never had an undetected error." - Weisert
"If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010