XOOPS  2.6.0
JUpload Class Reference

Public Member Functions

 defaultAfterUploadManagement ()
 
 interceptAfterUpload ($str)
 
 interceptBeforeUpload ($str)
 
 JUpload ($appletparams=array(), $classparams=array())
 
 uploadedfiles ()
 

Public Attributes

 $appletparams
 
 $classparams
 
 $files
 

Protected Member Functions

 logDebug ($function, $msg, $htmlComment=true)
 
 logPHPDebug ($function, $msg)
 

Private Member Functions

 abort ($msg= '')
 
 arrayexpand ($array)
 
 cleanup ()
 
 dstfinal (&$name, &$subdir)
 
 generateAppletTag ($str)
 
 mkdirp ($path)
 
 page_start ()
 
 receive_debug_log ()
 
 receive_uploaded_files ()
 
 str_applet ()
 
 str_jsinit ()
 
 tobytes ($val)
 
 warning ($msg= '')
 

Detailed Description

This class manage upload, with use of the JUpload applet. It's both a sample to show how to use the applet, and a class you can use directly into your own application.

Recommandation: Don't update its code !

By doing this, you'll be able to reuse directly any update coming from the JUpload project, instead of reporting your modifications into any new version of this class. This guarantees you that your project can use the last version of JUpload, without any code modification. We work so that the applet behavior remains unchanged, but from time to time, a change can appear.

Sample:

  • See the index.php samples, in the same folder.

Notes:

  • maxChunkSize: this class use a default maxChunkSize of 500K (or less, depending on the script max size). This allows upload of FILES OF ANY SIZE on quite all ISP hosting. If it's too big for you (the max upload size of your ISP is less than 500K), or if you want no chunk at all, you can, of course, override this default value.

Parameters:

  • $appletparams contains a map for applet parameters: key is the applet parameter name. The value is the value to transmit to the applet. See the applet documentation for information on all applet parameters.
  • $classparams contains the parameter specific for the JUpload class below. Here are the main class parameters:
    • demo_mode. Files are uploaded to the server, but not stored on its hard drive. That is: you can simulate the global behavior, but won't consume hard drive space. This mode is used on sourceforge web site.

Output generated for uploaded files:

  • $files is an array of array. This can be managed by (a) the function given in the callbackAfterUploadManagement class parameter, or (b) within the page whose URL is given in the afterUploadURL applet parameter, or (c) you can Extend the class and redeclare defaultAfterUploadManagement() to your needs. See the defaultAfterUploadManagement() for a sample on howto manage this array.

    This array contains:

    • One entry per file. Each entry is an array, that contains all files properties, stored as $key=>$value. The available keys are:

      • name: the filename, as it is now stored on the system.
      • size: the file size
      • path: the absolute path, where the file has been stored.
        • fullName: the canonical file name (i.e. including the absolute path)
      • md5sum: the md5sum of the file, if further control is needed.
        • mimetype: the calculated mime type of the file
      • If the formData applet parameter is used: all attributes (key and value) uploaded by the applet, are put here, repeated for each file.

      Note: if you are using a callback function (i.e. callbackAfterUploadManagement) and you do not see a global 'object' you are expecting then it might have been destroyed by PHP - c.f. http://bugs.php.net/bug.php?id=39693

Definition at line 55 of file jupload.php.

Member Function Documentation

JUpload::abort (   $msg = '')
private

Definition at line 310 of file jupload.php.

References $msg, cleanup(), and exit.

Referenced by dstfinal(), JUpload(), mkdirp(), page_start(), and receive_uploaded_files().

Here is the call graph for this function:

Here is the caller graph for this function:

JUpload::arrayexpand (   $array)
private

Definition at line 221 of file jupload.php.

JUpload::cleanup ( )
private

Definition at line 325 of file jupload.php.

References $_SESSION.

Referenced by abort(), and warning().

Here is the caller graph for this function:

JUpload::defaultAfterUploadManagement ( )

Example function to process the files uploaded. This one simply displays the files' data.

Definition at line 419 of file jupload.php.

References $files, and logDebug().

Referenced by interceptAfterUpload().

Here is the call graph for this function:

Here is the caller graph for this function:

JUpload::dstfinal ( $name,
$subdir 
)
private

This method:

  • Replaces some potentially dangerous characters by '_' (in the given name an relative path)
  • Checks if a files of the same name already exists.
    • If no: no problem.
    • If yes, and the duplicate class param is set to rename, the file is renamed.
    • If yes, and the duplicate class param is set to overwrite, the file is not renamed. The existing one will be erased.
    • If yes, and the duplicate class param is set to reject, an error is thrown.

Definition at line 364 of file jupload.php.

References $dir, $ext, $name, $subdir, abort(), mkdirp(), and warning().

Referenced by receive_uploaded_files().

Here is the call graph for this function:

Here is the caller graph for this function:

JUpload::generateAppletTag (   $str)
private

Generation of the applet tag, and necessary things around (js content). Insertion of this into the content of the page. See the tag_jscript and tag_applet class parameters.

Definition at line 461 of file jupload.php.

References logDebug(), str_applet(), and str_jsinit().

Referenced by interceptAfterUpload(), and interceptBeforeUpload().

Here is the call graph for this function:

Here is the caller graph for this function:

JUpload::interceptAfterUpload (   $str)

This function displays the uploaded files description in the current page (see tag_flist class parameter)

This must be public, because it is called from PHP's output buffering.

Definition at line 483 of file jupload.php.

References defaultAfterUploadManagement(), generateAppletTag(), logDebug(), and logPHPDebug().

Here is the call graph for this function:

JUpload::interceptBeforeUpload (   $str)

This function is called when constructing the page, when we're not reveiving uploaded files. It 'just' construct the applet tag, by calling the relevant function.

This must be public, because it is called from PHP's output buffering

Definition at line 473 of file jupload.php.

References generateAppletTag(), and logDebug().

Here is the call graph for this function:

JUpload::JUpload (   $appletparams = array(),
  $classparams = array() 
)

Definition at line 61 of file jupload.php.

References $_SERVER, $appletparams, $classparams, abort(), page_start(), and tobytes().

Here is the call graph for this function:

JUpload::logDebug (   $function,
  $msg,
  $htmlComment = true 
)
protected

Log a message on the current output, as a HTML comment.

Definition at line 201 of file jupload.php.

Referenced by defaultAfterUploadManagement(), generateAppletTag(), interceptAfterUpload(), interceptBeforeUpload(), page_start(), and receive_uploaded_files().

Here is the caller graph for this function:

JUpload::logPHPDebug (   $function,
  $msg 
)
protected

Log a message to the PHP log. Declared "protected" so it may be Extended if you require customised logging (e.g. particular log file location).

Definition at line 214 of file jupload.php.

References $msg.

Referenced by interceptAfterUpload(), and receive_debug_log().

Here is the caller graph for this function:

JUpload::mkdirp (   $path)
private

Definition at line 339 of file jupload.php.

References $dir, $path, and abort().

Referenced by dstfinal().

Here is the call graph for this function:

Here is the caller graph for this function:

JUpload::page_start ( )
private

Definition at line 713 of file jupload.php.

References $_SERVER, $_SESSION, $files, abort(), logDebug(), receive_debug_log(), and receive_uploaded_files().

Referenced by JUpload().

Here is the call graph for this function:

Here is the caller graph for this function:

JUpload::receive_debug_log ( )
private

This method manages the receiving of the debug log, when an error occurs.

Definition at line 502 of file jupload.php.

References $_SERVER, $msg, exit, and logPHPDebug().

Referenced by page_start().

Here is the call graph for this function:

Here is the caller graph for this function:

JUpload::receive_uploaded_files ( )
private

This method is the heart of the system. It manage the files sent by the applet, check the incoming parameters (md5sum) and reconstruct the files sent in chunk mode.

The result is stored in the $files array, and can then be managed by the function given in the callbackAfterUploadManagement class parameter, or within the page whose URL is given in the afterUploadURL applet parameter. Or you can Extend the class and redeclare defaultAfterUploadManagement() to your needs.

Definition at line 524 of file jupload.php.

References $_SESSION, $files, $mimetypes, abort(), dstfinal(), exit, fix_dirname(), and logDebug().

Referenced by page_start().

Here is the call graph for this function:

Here is the caller graph for this function:

JUpload::str_applet ( )
private

Build a string, containing the applet tag with all parameters.

Returns
A string, containing the applet tag

Definition at line 282 of file jupload.php.

References $appletparams.

Referenced by generateAppletTag().

Here is the caller graph for this function:

JUpload::str_jsinit ( )
private

Build a string, containing a javascript wrapper function for setting applet properties via JavaScript. This is necessary, because we use the "modern" method of including the applet (using <object> resp. <embed> tags) in order to trigger automatic JRE downloading. Therefore, in Netscape-like browsers, the applet is accessible via the document.embeds[] array while in others, it is accessible via the document.applets[] array.

Returns
A string, containing the necessary wrapper function (named JUploadSetProperty)

Definition at line 263 of file jupload.php.

References $name.

Referenced by generateAppletTag().

Here is the caller graph for this function:

JUpload::tobytes (   $val)
private

Convert a value ending in 'G','M' or 'K' to bytes

Definition at line 238 of file jupload.php.

References fix_strtolower().

Referenced by JUpload().

Here is the call graph for this function:

Here is the caller graph for this function:

JUpload::uploadedfiles ( )

Return an array of uploaded files * The array contains: name, size, tmp_name, error, relativePath, md5sum, mimetype, fullName, path

Definition at line 194 of file jupload.php.

References $files.

JUpload::warning (   $msg = '')
private

Definition at line 317 of file jupload.php.

References $msg, cleanup(), and exit.

Referenced by dstfinal().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

JUpload::$appletparams

Definition at line 57 of file jupload.php.

Referenced by JUpload(), and str_applet().

JUpload::$classparams

Definition at line 58 of file jupload.php.

Referenced by JUpload().

JUpload::$files

The documentation for this class was generated from the following file: