title: PHP - file_get_contents(): Filename cannot be empty
body: <p>Can someone help me to handle this error? I don't know what method or way to get rid of this error. Im new to php and starting to learn it. Can someone give me ideas? </p>
  
  <p>here is the error :
  <a href="https://i.stack.imgur.com/yETNJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yETNJ.png" alt="enter image description here"></a></p>
  
  <p>here is my php code.</p>
  
  <pre><code>&lt;?php
  
  include_once('connection.php');
  
   $newsid = $_GET['news_id'];
  
      if(isset($_POST['esubmit'])){
          /* create a prepared statement */
          if ($stmt = mysqli_prepare($con, "SELECT * FROM news WHERE news_id = ? LIMIT 1")) {
              /* bind parameters */
              mysqli_stmt_bind_param($stmt, "s", $newsid);
  
              /* execute query */
              mysqli_stmt_execute($stmt);
  
              /* get the result set */
              $result = mysqli_stmt_get_result($stmt);
  
              /* fetch row from the result set */
              $row = mysqli_fetch_array($result);
          }
  
      }
  
  
      if(isset($_POST['update'])){
  
          if(isset($_FILES['image'])){
            $file=$_FILES['image']['tmp_name'];
            /* Below is the line 30 causing the error*/
            $image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
            $image_name= addslashes($_FILES['image']['name']);
            move_uploaded_file($_FILES["image"]["tmp_name"],"img/" . $_FILES["image"]["name"]);
            $newsimage="img/" . $_FILES["image"]["name"];
  
            $title = $_POST['titles'];
            $date = $_POST['dates'];
            $content = $_POST['contents'];
  
            $sql ="UPDATE news SET news_title ='$title', news_date ='$date', news_content = '$content', news_image ='$newsimage' WHERE news_id = '$newsid'";
            mysqli_query($con, $sql);
            echo "oh it worked ";
          }
          else{
            $title = $_POST['titles'];
            $date = $_POST['dates'];
            $content = $_POST['contents'];
            $sql ="UPDATE news SET news_title ='$title', news_date ='$date', news_content = '$content' WHERE news_id = '$newsid'";
            mysqli_query($con, $sql);
            echo "oh it worked again ";
          }
  
      }
  ?&gt;
  &lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;?php
  
      if(isset($_POST['esubmit'])){
          ?&gt;
  
          &lt;form method="post" action ="edit2.php?news_id=&lt;?php echo $row['news_id']; ?&gt;" enctype="multipart/form-data"&gt;
              Title&lt;input type ="text" name ="titles" value="&lt;?php echo $row['news_title']; ?&gt;"/&gt;&lt;br&gt;
              Date&lt;input type ="text" name="dates" value="&lt;?php echo $row['news_date']; ?&gt;" /&gt;&lt;br&gt;
              Content&lt;textarea name="contents"&gt;&lt;?php echo $row['news_content']; ?&gt;&lt;/textarea&gt;
              &lt;input class="form-control" id="image" name="image" type="file" accept="image/*" onchange='AlertFilesize();'/&gt;
              &lt;img id="blah" src="&lt;?php echo $row['news_image']; ?&gt;" alt="your image" style="width:200px; height:140px;"/&gt;
  
              &lt;input type="submit" name="update" value="Update" /&gt;
          &lt;/form&gt;
  
          &lt;?php
      }
  
  ?&gt;
  
  &lt;script src="js/jquery-1.12.4.min.js"&gt;&lt;/script&gt;
  &lt;script src="js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      function readURL(input) {
          if (input.files &amp;&amp; input.files[0]) {
              var reader = new FileReader();
  
              reader.onload = function (e) {
                  $('#blah').attr('src', e.target.result);
              }
  
              reader.readAsDataURL(input.files[0]);
          }
      }
  
      $("#image").change(function(){
          readURL(this);
      });
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>