Jump to content

File Upload using IFrame and XML workaround, without AJAX. Code:


zardiw

Recommended Posts

Quick and easy way to upload a file without reloading your webpage. How To upload a file asynchronous method.

 

 

		<FORM ID="FrmDlyUpload" target="FrmDlyIFrame" enctype="multipart/form-data"  method="post" action="AmandaUpload.php">
        <P align="center"><B>Upload Daily EOD File</B></P>
        <P align="center"> 
          <INPUT type="file" ID="FrmDlyFile" name="FrmDlyFile" size="60">
        </P>
        <P align="center"> 
          <INPUT type="Submit" name="FrmDlyBtn" value="Upload Daily">
        </P>
        <P align="center"><B>Status: 
          <IFRAME id="FrmDlyIFrame" name="FrmDlyIFrame" style="width:300px;height:25px;border:2px solid #ffffff;"></IFRAME> 
          </B></P>
	 </FORM> 

 

 

PHP File Code (From AmandaUpload.php):

 

                 // Upload Daily File

		  
$target_path = "/XXXXXXX/lXXX/XXXX/XXXXX/XXXXX/PHP/";
$UpdFileNm = basename($_FILES['FrmDlyFile']['name']);
$target_path = $target_path . $UpdFileNm; 

if (move_uploaded_file($_FILES['FrmDlyFile']['tmp_name'], $target_path)) {
    $returnData = 'EOD File Uploaded';
} else{
       switch ($_FILES['FrmDlyFile'] ['error']) {
        case 1:
                   $returnData = 'File exceeds PHP';
                   break;
            case 2:
                   $returnData =  'File exceeds form';
                   break;
            case 3:
                   $returnData =  'Partial Upload';
                   break;
            case 4:
                   $returnData =  'No file was uploaded';
                   break;
       }
}
print ($returnData . ': ' . $UpdFileNm);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.