Uploading a file with symfony 1.4

This is a way to upload a file manually in Symfony 1.4. ie: without going through the forms framework.

        foreach ($request->getFiles() as $fileName) {

            $fileSize = $fileName['size'];
            $fileType = $fileName['type'];
            $theFileName = $fileName['name'];
            $uploadDir = sfConfig::get("sf_upload_dir");
            $Contacts_uploads = $uploadDir.'/contacts_uploads';

            if(!is_dir($Contacts_uploads))
                mkdir($Contacts_uploads, 0777);            

            move_uploaded_file($fileName['tmp_name'], "$Contacts_uploads/$theFileName");

        }

你可能感兴趣的:(PHP,symfony)