This script takes care of the common problem of getting lots of files up to your server. Your traditional form uploader does not handle multiple file uploads and forces you painfully to process each upload individually. Using this Flash and jQuery based uploader you can shift select a whole bunch of files and upload them at the same time with progress bars! How cool is that? Well this is one of those things that you have to try out for yourself.
Preview:

Step 1 (create a common include [_common.jSwfUploader.php]):
-
<?
-
// shared by both both the client and the uploader
-
// http://thedevnet.com/php/classes/multiple-file-uploading-with-php/
-
// include class
-
require_once('_class.jSwfUploader.php');
-
// create object
-
$multiUpload = new multiUploader();
-
-
// change any default variables here:
-
$multiUpload->file_size_limit = 2024; // 2024 KB
-
?>
view more variables...
-
$multiUpload->jqueryjs ="js/jquery-1.3.2.js";
-
$multiUpload->swfuploadjs ="js/swfupload/swfupload.js";
-
$multiUpload->jqueryswfuploadjs="js/jquery.swfupload.js";
-
-
$multiUpload->upload_url = "upload-file.php";
-
$multiUpload->file_post_name = "uploadfile";
-
$multiUpload->file_size_limit = 1024;
-
-
$multiUpload->file_types = '*.jpg;*.gif;*.png';
-
$multiUpload->file_types_description = "images";
-
$multiUpload->file_upload_limit = 5;
-
$multiUpload->flash_url = "js/swfupload/swfupload.swf";
-
$multiUpload->button_image_url = 'js/swfupload/wdp_buttons_upload_114×29.png';
-
$multiUpload->button_width = 114;
-
$multiUpload->button_height = 29;
-
$multiUpload->debug = 'false';
-
-
$multiUpload->uploaddir = "./uploads";
Step 2 (your basic upload client):
-
<?
-
// http://thedevnet.com/php/classes/multiple-file-uploading-with-php/
-
include_once('_common.jSwfUploader.php');
-
?>
-
<html>
-
<head>
-
<title>My Test jQuery SWF Multiple File Uploads Using PHP</title>
-
<link href="jSWFUpload.css" rel="stylesheet" type="text/css" />
-
<? $multiUpload->headjs() ?>
-
</head>
-
-
<body>
-
<? $multiUpload->fileform() ?>
-
</body>
-
</html>
Step 3 (your basic upload handler):
-
<?php
-
require_once('_common.jSwfUploader.php');
-
-
$uploaddir = $multiUpload->uploaddir;
-
$maxfilesize = $multiUpload->file_size_limit;
-
$filepostname= $multiUpload->file_post_name;
-
-
-
$file = $uploaddir . basename($_FILES[$filepostname]['name']);
-
$size=$_FILES[$filepostname]['size'];
-
-
if($size>maxfilesize*1024)
-
{
-
echo "error file size > max allowed size";
-
unlink($_FILES[$filepostname]['tmp_name']);
-
exit;
-
}
-
if (move_uploaded_file($_FILES[$filepostname]['tmp_name'], $file)) {
-
echo "success";
-
} else {
-
echo "error ".$_FILES[$filepostname]['error']." — ".$_FILES[$filepostname]['tmp_name']." %%% ".$file."($size)";
-
}
-
?>
Do away with the one at a time file uploading restriction on traditional forms. Requires flash plugin.
| Platforms: |
Web Based |
| Date: |
October 21, 2009 |
GD Star Rating
loading...
Originally posted 2009-10-21 04:28:16.
Popularity: 100%
Posted by irbobo @ 2 September 2010
5:56 pm
I don’t even know where to begin to elate how awesome this script is. Really does some amazing stuff.
loading...