Jump to content

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


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);
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.