2

I have the following code to upload the file but I cannot get the file at the php someone knows explain why ?

EXT JS

items:
 [{
    xtype: 'textfield',
    fieldLabel: "Anexo",
    id: 'anexohelp',
    name: 'anexohelp',
    inputType:'file',
 }]

PHP

$file     = $_FILES['anexohelp'];
$filename = $file['name'];

Thanks.

1 Answer 1

2

you can get file using this $_FILES["file_name_here"] and you will get here all documentation here

and example

<?php
   if(isset($_FILES['image'])){
      $errors= array();
      $file_name = $_FILES['image']['name'];
      $file_size =$_FILES['image']['size'];
      $file_tmp =$_FILES['image']['tmp_name'];
      $file_type=$_FILES['image']['type'];
      $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));

      $expensions= array("jpeg","jpg","png");

      if(in_array($file_ext,$expensions)=== false){
         $errors[]="extension not allowed, please choose a JPEG or PNG file.";
      }

      if($file_size > 2097152){
         $errors[]='File size must be excately 2 MB';
      }

      if(empty($errors)==true){
         move_uploaded_file($file_tmp,"images/".$file_name);
         echo "Success";
      }else{
         print_r($errors);
      }
   }
?>

  <form action="" method="POST" enctype="multipart/form-data">
     <input type="file" name="image" />
     <input type="submit"/>
  </form>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.