Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. PHP - Warning: fopen(): Filename cannot be empty

PHP - Warning: fopen(): Filename cannot be empty

Scheduled Pinned Locked Moved Web Development
helpphp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    M Riaz Bashir
    wrote on last edited by
    #1

    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
    
    J W 2 Replies Last reply
    0
    • M M Riaz Bashir

      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
      
      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      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.

      M 1 Reply Last reply
      0
      • J Jochen Arndt

        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.

        M Offline
        M Offline
        M Riaz Bashir
        wrote on last edited by
        #3

        I check it Thank you

        1 Reply Last reply
        0
        • M M Riaz Bashir

          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
          
          W Offline
          W Offline
          W Balboos GHB
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups