views:

71

answers:

2

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;

  }
+1  A: 

If you

Zend_Debug::dump($_FILES);

Do you see your file?

Iznogood
I see this:array(1) { ["icon"] => array(5) { ["name"] => string(8) "test.csv" ["type"] => string(8) "text/csv" ["tmp_name"] => string(14) "/tmp/phpcdvLDl" ["error"] => int(0) ["size"] => int(793) }}
Stackfan
Then the file is there. Google for some tutorials on how to move the file from there. google move_uploaded_file()
Iznogood
@Iznogood $form->file->receive(); is enough. You don't need to use move_uploaded_file().
Richard Knop
@Richard Knop hey the more you know!! I am so used to using move_uploaded_files I`ll check it out!
Iznogood
A: 

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/

nvoyageur