try this- function upload(){
- if(count($_FILES["item_file"]['name'])>0) { //check if any file uploaded
- $GLOBALS['msg'] = ""; //initiate the global message
- for($j=0; $j < count($_FILES["item_file"]['name']); $j++) { //loop the uploaded file array
- $filen = $_FILES["item_file"]['name']["$j"]; //file name
- $path = 'webupload/'.$filen; //generate the destination path
- if(move_uploaded_file($_FILES["item_file"]['tmp_name']["$j"],$path)) { //upload the file
- $GLOBALS['msg'] .= "File# ".($j+1)." ($filen) uploaded successfully<br>"; //Success message
- }
- }
- }
- else {
- $GLOBALS['msg'] = "No files found to upload"; //Failed message
- }
- //uploadForm(); //display the main form
- header('Location: ?msg='.urlencode($GLOBALS['msg']));
- }
複製代碼 and in the uploadForm(), change- <?php if ($GLOBALS['msg']) { echo '<center><span class="err">'.$GLOBALS['msg'].'</span></center>'; }?>
複製代碼 to- <?php if ($_GET['msg']) { echo '<center><span class="err">'.$_GET['msg'].'</span></center>'; }?>
複製代碼 |