WebSite-PHP Framework PHP
Multi langues
Mode Ajax simple
Aucun HTML, aucun JavaScript
URL rewrinting
Envoi d'email
Sitemap - RSS - Web service
Télécharger le Framework WebSite-PHP maintenant
 


Loading
 


Tutorial : Drop files on a zone
    and specific a wait object (ajax event)

Tutoriels

>

Tutoriel Uploadfile

>

Tutorial : Drop files on a zone and specific a wait object (ajax event)


Uploadfile-08: Tutoriel du composants Uploadfile du FrameWork PHP WebSite-PHP.

Tutorial : Drop files on a zone and specific a wait object (ajax event):





Drop your files in this zone to upload


Retourner aux tutoriels du composants Uploadfile



Code source

Code source


Fichier: /pages/tutorials/uploadfile/uploadfile-08.php

<?php
class Uploadfile08 extends Page {
    public function 
InitializeComponent() {
        
parent::$PAGE_TITLE "Tutorial : Drop files on a zone
            and specific a wait object (ajax event)"
;
        
        
// create upload file
        
$this->uploads = new UploadFile($this);
        
$this->uploads->activateMultipleFiles();

        
// Drop zone
        // See compatible browser list: http://caniuse.com/#feat=fileapi
        
$drop_zone_lbl = new Label("Drop your files in this zone to upload"true);
        
$drop_zone_obj = new WSPObject("<br/><br/><br/><br/>"$drop_zone_lbl);
        
$drop_zone_obj->setId("drop_zone_id_8");
        
$drop_zone_obj->setWidth(400)->setHeight(150);
        
$drop_zone_obj->setAlign(WSPObject::ALIGN_CENTER);
        
$drop_zone_obj->setStyle("border: 1px dashed #BBBBBB;");

        
// Create wait progress bar object
        
$wait_obj $this->uploads->getProgressBarObject();
        
$wait_obj->setWidth(300)->setHeight(18);
        
$this->uploads->setAjaxWaitMessage($wait_obj);
        
$drop_zone_obj->add($wait_obj);

        
// Set drop zone on upload object
        
$this->uploads->setObjectDropZone($drop_zone_obj);
        
        
// define mime type authorized 
        
$this->uploads->setAuthorizedMimeTypes(array(
                
"image/jpeg","image/png""image/gif"));
        
        
// define file size limit
        
$this->uploads->setFileSizeLimit("300kb");
        
        
// define the event method
        
$this->uploads->setAjaxEvent();
        
$this->uploads->onChange("onUploads");
        
        
$this->render $this->uploads;
    }

    public function 
onUploads($sender) {
        
// check the files are correctly uploaded
        
for ($i $i $this->uploads->count(); $i++) {
            if (
$this->uploads->checkMimeType($i) &&
                
$this->uploads->checkFileSize($i)) {
                
alert("File ".$this->uploads->getFileName($i)." (".
                    
$this->uploads->getFileSize($i).") uploaded !");
            } else if (
$this->uploads->isEmptyFile($i)) {
                
alert("Your file ".$this->uploads->getFileName($i)." is empty !");
            } else if (!
$this->uploads->checkFileSize($i)) {
                
alert("Your file ".$this->uploads->getFileName($i)." is too big !");
            } else {
                
alert("Mime type ".$this->uploads->getFileMimeType($i).
                    
" of the file ".$this->uploads->getFileName($i).
                    
" is not supported !");
            }
        }
    }
}
?>


Retourner aux tutoriels du composants Uploadfile


Share

 


Copyright © 2009-2024 WebSite-PHP Framework PHP
Accueil Documentation Télécharger Quick start Tutoriels Wiki Issue Tracker