onion2k,
Thank you for your reply, As i have said on my previous post, the script is already
there and is working just fine for a single upload. So the thing i'm looking is
to implement the multiple uploads on the same script.
I have tried to increase options manual (files inputs), but it is only uploading a single file even though you have selected 4 or 5 files. I know it needs to be changed somewhere on
php or
java script codes as this script uses both languages. And the issue here is, i'm not good on both languages, only good on html.
these codes are on my
temporary test page in here, All other source codes are
here:
Code: Select all
<?php
@set_time_limit(90); // try to change to maximum allowed execution time for this page
define('CFG_UPLOADFOLDER','_uploadedfiles_xxxxx/');
$bSecure = (isset($_SERVER['HTTPS']))? true : false;
include('inc.ErrorHandling.php');
include('inc.init.php');
include('class.DataException.php');
include('class.File.php');
function ProduceJavaScriptResponse($aResponse){
$response = <<<EOD
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="Cache-Control" content="no cache" >
<meta http-equiv="Pragma" content="no_cache" >
<meta name="language" content="en" >
</head>
<body>
<script type="text/javascript">{code}</script>
</body></html>
EOD;
// encode into JSON
$jsResponse = 'window.parent.'. $_REQUEST['callback'] .'('. json_encode($aResponse) .');';
$response = str_replace('{code}', $jsResponse, $response);
return $response;
}
// Upload file
$errorMessage = '';
$aResponse = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
############################################################
if (!headers_sent()){
Header("Pragma: no-cache");
Header("Cache-Control: no-cache");
Header('Expires: '. GMDate("D,d M Y H:i:s") .' GMT');
}
$blacklist = array('.php', '.phtml', '.php3', '.php4');
foreach ($blacklist as $item) {
if (preg_match("/$item\$/i", $_FILES['_file']['name'])){
$errorMessage = 'Uploading PHP files is not allowed!';
}
}
try{
if ($errorMessage == ''){
$maxAllowedSize = null; // no limit (see FAQ)
$aAllowedContenTypes = null; // any file (see FAQ)
$oFile = File::UploadFile('_file', CFG_UPLOADFOLDER, $maxAllowedSize, $aAllowedContenTypes);
}
}catch(Exception $e){
$errorMessage = 'An error occured:'. $e->getMessage();
}
// produce response
if (isset($_REQUEST['output']) && $_REQUEST['output'] == 'js'){
if (!isset($_REQUEST['callback']) || empty($_REQUEST['callback'])){
// ERROR: BAD AJAX call
$errorMessage = "Bad Ajax call! URL argument \'callback\' was not specified.";
die('<script type="text/javascript">alert("'. $errorMessage .'");</script>');
}else if(empty($errorMessage) && $oFile){
// SUCCESS (file was uploaded)
$aResponse['result'] = 'success';
$aResponse['file'] = array('size' => $oFile->getSize(),
'sizeFormatted' => $oFile->FormatFileSize($oFile->getSize()),
'name' => $oFile->getName()
);
}else{
// UPLOAD ERROR
$aResponse['result'] = 'failure';
$aResponse['message'] = 'Upload error ('. $errorMessage .').';
}
$response = ProduceJavaScriptResponse($aResponse);
}else{
$response = file_get_contents('fileUploaded.tpl.php');
$aValues = array($oFile->getName(), $oFile->FormatFileSize($oFile->getSize()));
$aPlaceHolders = array('{filename}', '{filesize}');
$response = str_replace($aPlaceHolders,$aValues,$response,$count);
}
die($response);
############################################################
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="language" content="en" >
<meta name="description" content="Secure file uploading : a page for uploading files securely">
<meta name="author" content="attila szabo (http://www.w3net.eu)" >
<meta name="robots" content="noindex,nofollow" >
<title><?php if($bSecure){echo 'Secure ';}?>File Upload form</title>
<link media="handheld" href="css/handheld.css" type="text/css" rel="stylesheet">
<link rel="stylesheet" type="text/css" media="all" href="css/main.css">
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/FileListing.js"></script>
<script type="text/javascript" src="js/PageController.js"></script>
</head>
<body id="home">
<div id="container">
<ul id="skip">
<li><a href="#main">Skip to main content</a></li>
<li><a href="#form">Skip to the upload form</a></li>
</ul>
<iframe id="uploadIfr" src="blank.htm" name="uploadIfr" class="hiddenUploadIframe" title="ignore this frame"></iframe>
<!-- @@@ listing of uploaded files -->
<div id="uploadedFiles">
</div>
<!-- end listing of uploaded files @@@ -->
<a name="main"></a>
<h1><?php if($bSecure){echo 'Secure file';}else{echo 'File';}?> uploading</h1>
<?php
if($bSecure){
?>
<p class="message" id="annotationSecure">
Uploading files using this web page is secure. This webpage transmits the file using a high-level encryption so that
only I will be able to access the information.
Web pages beginning with "https" instead of "http" enable secure information transmission.
</p><?php
}else{
echo "<p></p>";
}
?>
<div id="frmAttachFile_ErrorMessage" class="form_boxErrorMsg" style="display: none"></div>
<!-- @@@ file upload form -->
<div id="fileuploadForm"><a name="form"></a>
<form name='frmUploadFile' id="frmUploadFile" action="index.php" method="post" enctype="multipart/form-data" > <!-- uploadIfr -->
<fieldset title="Choose the file to upload">
<legend> 1: Choose a file to upload</legend>
<p>Click the button to browse the file system of your computer. Find and select the file you want to upload.</p>
<label for="fileInput" class="form_label">File:</label>
<input type="file" accept="" name="_file" id="fileInput" ><br>
<label for="fileInput" class="form_label">File:</label>
<input type="file" accept="" name="_file" id="fileInput" ><br>
<label for="fileInput" class="form_label">File:</label>
<input type="file" accept="" name="_file" id="fileInput" ><br>
<label for="fileInput" class="form_label">File:</label>
<input type="file" accept="" name="_file" id="fileInput" ><br>
<label for="fileInput" class="form_label">File:</label>
<input type="file" accept="" name="_file" id="fileInput" ><br>
</fieldset>
<fieldset id="confirmation" title="Confirmation">
<legend> 2: Upload file</legend>
<p>When you have selected the file to upload, click on the <strong>Upload</strong> button.</p>
<div class="actionBar" id="submitBtnBox">
<input type="submit" value="Upload" >
</div>
</fieldset>
</form>
</div>
<!-- end file upload form @@@ -->
</div>
</body></html>
If is possible for anybody to help me, Again I will be much appreciated for that.
Hope to get help from you guys.
Many thanks.