title: IMAGE COMPRESSOR Script [ Notice: Only variables should be passed by reference in ]
body: <p>I tried to take it off this error I do not understand why it happens, because I am uploading the file correctly... Right now is uploading the files, it shows me the error Error Notice: Only variables should be passed by reference in...</p>
  <blockquote>
  <p>Notice: Only variables should be passed by reference in
  D:\xampp\htdocs\reduce-image\upload.php on line 10
  **
  I am facing in upload.php code. It's showing this error:</p>
  </blockquote>
  <p>**</p>
  <pre><code>```   
  **upload.php**
  &lt;pre&gt;
  &lt;?php 
      $file_type_error = '';
      if($_FILES['upload_images']['name']) {    
          $upload_dir = &quot;uploads/&quot;;   
          if (($_FILES[&quot;upload_images&quot;][&quot;type&quot;] == &quot;image/gif&quot;) ||
             ($_FILES[&quot;upload_images&quot;][&quot;type&quot;] == &quot;image/jpeg&quot;) ||
             ($_FILES[&quot;upload_images&quot;][&quot;type&quot;] == &quot;image/png&quot;) ||
             ($_FILES[&quot;upload_images&quot;][&quot;type&quot;] == &quot;image/pjpeg&quot;)) {
              $file_name = $_FILES[&quot;upload_images&quot;][&quot;name&quot;];
              $extension = end((explode(&quot;.&quot;, $file_name)));
              $upload_file = $upload_dir.$file_name;      
              if(move_uploaded_file($_FILES['upload_images']['tmp_name'],$upload_file)){            
                   $source_image = $upload_file;
                   $image_destination = $upload_dir.&quot;min-&quot;.$file_name;
                   $compress_images = compressImage($source_image, $image_destination);            
              }        
          } else {
              $file_type_error = &quot;Upload only jpg or gif or png file type&quot;;
          }   
      }
      // created compressed JPEG file from source file
      function compressImage($source_image, $compress_image) {
          $image_info = getimagesize($source_image);  
          if ($image_info['mime'] == 'image/jpeg') { 
              $source_image = imagecreatefromjpeg($source_image);
              imagejpeg($source_image, $compress_image, 75);
          } elseif ($image_info['mime'] == 'image/gif') {
              $source_image = imagecreatefromgif($source_image);
              imagegif($source_image, $compress_image, 75);
          } elseif ($image_info['mime'] == 'image/png') {
              $source_image = imagecreatefrompng($source_image);
              imagepng($source_image, $compress_image, 6);
          }       
          return $compress_image;
      }
  ?&gt;
  &lt;/pre&gt; ```
  </code></pre>
  <pre><code>  &lt;pre&gt;
  &lt;?php 
  include('header.php');
  ?&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;scripts/jquery.form.js&quot;&gt;&lt;/script&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;scripts/upload.js&quot;&gt;&lt;/script&gt;
  &lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;style.css&quot; /&gt;
  
  &lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;style.css&quot; /&gt;
  &lt;div class=&quot;container&quot;&gt;
   &lt;h2&gt;Reduce or Compress Image Size While Uploading in PHP&lt;/h2&gt;       
   &lt;form method=&quot;post&quot; name=&quot;upload_form&quot; id=&quot;upload_form&quot; enctype=&quot;multipart/form-data&quot; action=&quot;upload.php&quot;&gt;   
   &lt;label&gt;Choose Images to Upload&lt;/label&gt;  
   &lt;input type=&quot;file&quot; name=&quot;upload_images&quot; id=&quot;image_file&quot;&gt;
   &lt;div class=&quot;file_uploading hidden&quot;&gt;
       &lt;label&gt; &lt;/label&gt;
       &lt;img src=&quot;uploading.gif&quot; alt=&quot;Uploading......&quot;/&gt;
   &lt;/div&gt;
   &lt;/form&gt;
   &lt;div id=&quot;uploaded_images_preview&quot;&gt;
   &lt;/div&gt;  
  &lt;/div&gt;
  &lt;?php include('footer.php');?&gt;
  &lt;/pre&gt;`
  
  
  
  
  
  **js.file**
  &lt;pre&gt;
  $(document).ready(function(){
   $('#image_file').on('change',function(){
       $('#upload_form').ajaxForm({           
           target:'#uploaded_images_preview',
           beforeSubmit:function(e){
               $('.file_uploading').show();
           },
           success:function(e){
               $('.file_uploading').hide();
           },
           error:function(e){
           }
       }).submit();
   });
  });
  &lt;/pre&gt; ```
  </code></pre>