【问题标题】:Upload File Ext Js 2.2上传文件Ext Js 2.2
【发布时间】:2016-07-25 17:00:22
【问题描述】:

我有以下代码来上传文件,但我无法在 php 中获取文件,有人知道解释一下原因吗?

EXT JS

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

PHP

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

谢谢。

【问题讨论】:

    标签: javascript php extjs extjs2


    【解决方案1】:

    您可以使用此$_FILES["file_name_here"] 获取文件,您将在此处获取所有文档here

    例子

    <?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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-25
      • 1970-01-01
      • 1970-01-01
      • 2013-09-12
      • 2015-09-10
      • 2015-04-16
      • 2015-02-05
      • 2016-06-09
      相关资源
      最近更新 更多