WebSite-PHP Framework PHP
Mehrsprachig
Einfacher Ajax Modus
Kein HTML, kein JavaScript
URL Rewriting
Mails senden
Sitemap - RSS - Web service
Laden Sie WebSite-PHP FrameWork jetzt herunter
 


Loading
 


Tutorial : Upload a file 
with ajax event

Tutorials

>

Tutorial Uploadfile

>

Tutorial : Upload a file with ajax event


Uploadfile-02: Tutorial der Komponente Uploadfile vom PHP FrameWork WebSite-PHP.

Tutorial : Upload a file with ajax event:



Zurück zum Tutorial der Komponente Uploadfile



Quelltext

Quelltext


Datei: /pages/tutorials/uploadfile/uploadfile-02.php

<?php
class Uploadfile02 extends Page {
    public function 
InitializeComponent() {
        
parent::$PAGE_TITLE "Tutorial : Upload a file 
                    with ajax event"
;
        
        
// create upload file
        
$this->upload = new UploadFile($this);
        
        
// define mime type authorized 
        
$this->upload->setAuthorizedMimeTypes(array(
                
"image/jpeg","image/png""image/gif"));
        
        
// define file size limit
        
$this->upload->setFileSizeLimit("300kb");
        
        
// define the event method
        
$this->upload->setAjaxEvent();
        
$this->upload->onChange("onUpload");
        
        
$this->render $this->upload;
    }
    
    public function 
onUpload($sender) {
        
// check the file is correctly uploaded
        
if ($this->upload->checkMimeType() && 
            
$this->upload->checkFileSize()) {
                
alert("File ".$this->upload->getFileName()." (".
                    
$this->upload->getFileSize().") uploaded !");
        } else if (
$this->upload->isEmptyFile()) {
            
alert("Your file is empty !");
        } else if (!
$this->upload->checkFileSize()) {
            
alert("Your file is too big !");
        } else {
            
alert("Mime type ".$this->upload->getFileMimeType().
                    
" not supported !");
        }
    }
}
?>


Zurück zum Tutorial der Komponente Uploadfile


Share

 


Copyright © 2009-2016 WebSite-PHP Framework PHP
Start Dokumentation Herunterladen Schnellstart Tutorials Wiki Issue Tracker