[ Index ]
 

Code source de XOOPS 2.0.17.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/htdocs/class/ -> uploader.php (sommaire)

(pas de description)

Poids: 522 lignes (17 kb)
Inclus ou requis: 3 fois
Référencé: 0 fois
Nécessite: 1 fichier
 htdocs/class/uploader.php

Définit 1 class

XoopsMediaUploader:: (20 méthodes):
  XoopsMediaUploader()
  fetchMedia()
  setTargetFileName()
  setPrefix()
  getMediaName()
  getMediaType()
  getMediaSize()
  getMediaTmpName()
  getSavedFileName()
  getSavedDestination()
  upload()
  _copyFile()
  checkMaxFileSize()
  checkMaxWidth()
  checkMaxHeight()
  checkMimeType()
  checkImageType()
  sanitizeMultipleExtensions()
  setErrors()
  getErrors()


Classe: XoopsMediaUploader  - X-Ref

Upload Media files

Example of usage:
<code>
include_once 'uploader.php';
$allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png');
$maxfilesize = 50000;
$maxfilewidth = 120;
$maxfileheight = 120;
$uploader = new XoopsMediaUploader('/home/xoops/uploads', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);
if ($uploader->fetchMedia($_POST['uploade_file_name'])) {
if (!$uploader->upload()) {
echo $uploader->getErrors();
} else {
echo '<h4>File uploaded successfully!</h4>'
echo 'Saved as: ' . $uploader->getSavedFileName() . '<br />';
echo 'Full path: ' . $uploader->getSavedDestination();
}
} else {
echo $uploader->getErrors();
}
</code>

XoopsMediaUploader($uploadDir, $allowedMimeTypes, $maxFileSize=0, $maxWidth=null, $maxHeight=null)   X-Ref
Constructor

param: string  $uploadDir
param: array   $allowedMimeTypes
param: int     $maxFileSize
param: int     $maxWidth
param: int     $maxHeight
param: int     $cmodvalue

fetchMedia($media_name, $index = null)   X-Ref
Fetch the uploaded file

param: string  $media_name Name of the file field
param: int     $index      Index of the file (if more than one uploaded under that name)
return: bool

setTargetFileName($value)   X-Ref
Set the target filename

param: string  $value

setPrefix($value)   X-Ref
Set the prefix

param: string  $value

getMediaName()   X-Ref
Get the uploaded filename

return: string

getMediaType()   X-Ref
Get the type of the uploaded file

return: string

getMediaSize()   X-Ref
Get the size of the uploaded file

return: int

getMediaTmpName()   X-Ref
Get the temporary name that the uploaded file was stored under

return: string

getSavedFileName()   X-Ref
Get the saved filename

return: string

getSavedDestination()   X-Ref
Get the destination the file is saved to

return: string

upload($chmod = 0644)   X-Ref
Check the file and copy it to the destination

return: bool

_copyFile($chmod)   X-Ref
Copy the file to its destination

return: bool

checkMaxFileSize()   X-Ref
Is the file the right size?

return: bool

checkMaxWidth()   X-Ref
Is the picture the right width?

return: bool

checkMaxHeight()   X-Ref
Is the picture the right height?

return: bool

checkMimeType()   X-Ref
Check whether or not the uploaded file type is allowed

return: bool

checkImageType()   X-Ref
Check whether or not the uploaded image type is valid

return: bool

sanitizeMultipleExtensions()   X-Ref
Sanitize executable filename with multiple extensions


setErrors($error)   X-Ref
Add an error

param: string  $error

getErrors($ashtml = true)   X-Ref
Get generated errors

param: bool    $ashtml Format using HTML?
return: array|string    Array of array messages OR HTML string



Généré le : Sun Nov 25 11:44:32 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics