简体   繁体   中英

Zend Framework - how to upload a file

How can i upload a file? Stackoverflow i cant page codes so please check this link: http://pastebin.org/386639

Thanks in advance

LATER: Later i updated this as following, because ZF is not friendly, they keep still everything top secret! :P

  public static function mvUploadFile()
  {

    //
    // $_GET/_POST/FILE what ever
    //
    $fname = basename( $_FILES['attachment']['name']);
    $_fname = strtolower (end(explode('.',$fname) ) );
    Zend_Debug::dump(  $_FILES  );


    //
    // Filter the file 
    //
    switch($_fname)
    {
      case ($_fname == 'jpg'  ||
            $_fname == 'jpeg' ||
            $_fname == 'gif'  ||
            $_fname == 'bmp'  ||
            $_fname == 'png'  ||
            $_fname == 'html' ||
            $_fname == 'pdf'  ||
            $_fname == 'doc'  ||
            $_fname == 'docx' ||
            $_fname  == 'xls'
        ):
        $target_path = APPLICATION_PATH . "/../public/files/textual_translation_attachment/";
        //chmod("../up" , 0777);

        $target_path = $target_path .  basename( $_FILES['attachment']['name']);

        if(move_uploaded_file($_FILES['attachment']['tmp_name'], $target_path)) {
           //echo "The file ".  basename( $_FILES['file']['name']). " has been uploaded";
          //$_sql = "insert into a (huis,image) values ('$_app','$_file')";
          // send the file name only .....
          //echo  $fname ;
        }else{
          //echo "error ";
        }
      break;
    }


    return $fname;

  }

If you

Zend_Debug::dump($_FILES);

Do you see your file?

If you are using jQuery, you may want to try Uploadify. This can be done using the Zend Framework Uploadify Extension

http://gondo.webdesigners.sk/zend-framework-uploadify-extension/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM