WebSite-PHP Framework PHP
Multi language
Simple Ajax mode
No HTML, no JavaScript
URL rewriting
Mail sending
Sitemap - RSS - Web service
Download WebSite-PHP FrameWork now
 


Loading
 


Tutorial : Upload a file 
from icon with a specific wait object (ajax event)

Tutorials

>

Tutorial Uploadfile

>

Tutorial : Upload a file from icon with a specific wait object (ajax event)


Uploadfile-07: Tutorial of the composant Uploadfile of the PHP FrameWork WebSite-PHP.

Tutorial : Upload a file from icon with a specific wait object (ajax event):



Go back to tutorial of the componant Uploadfile



Source code

Source code


File: /pages/tutorials/uploadfile/uploadfile-07.php

<?php
class Uploadfile07 extends Page {
    public function 
InitializeComponent() {
        
parent::$PAGE_TITLE "Tutorial : Upload a file 
            from icon with a specific wait object (ajax event)"
;
        
        
// create upload file
        
$this->upload = new UploadFile($this);

        
// Create wait progress bar object
        
$wait_obj $this->upload->getProgressBarObject();
        
$wait_obj->setWidth(300)->setHeight(18);
        
$this->upload->setAjaxWaitMessage($wait_obj);
        
$upload_obj = new Table();
        
$upload_obj->addRowColumns($this->upload$wait_obj);

        
// Define the icon to select the file (replace the normal input)
        
$this->upload->setSelectFileIcon("img/paper_clip_32.png");
        
        
// 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 $upload_obj;
    }
    
    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 !");
        }
    }
}
?>


Go back to tutorial of the componant Uploadfile


Share

 


Copyright © 2009-2024 WebSite-PHP Framework PHP
Home Documentation Download Quick start Tutorials Wiki Issue Tracker