PHP iFrame Upload Confirmation

TYPEBREESSY

New Member
So i have a file upload feature on my site and rather than redirect to the php script page, I want to have an iframe that displays the message returned by the script. So here's my html:\[code\]<iframe class="iframe" name="my_iframe" src="http://stackoverflow.com/questions/12788835/upload_file.php" style="display:none;"></iframe><form id="uploadForm" action="upload_file.php" method="post" enctype="multipart/form-data" target="my_iframe">\[/code\]So basically I want to hide my iframe UNTIL I the upload process finishes and the script returns a message. Here's my php script:\[code\]<?php ini_set('display_errors', 'On'); error_reporting(E_ALL | E_STRICT); session_start(); $allowedExts = array("doc", "docx"); $extension = pathinfo( $_FILES["upload"]["name"],PATHINFO_EXTENSION); $username = $_SESSION["username"]; if (($_FILES["upload"]["size"] < 200000) && in_array($extension, $allowedExts)) { if ($_FILES["upload"]["error"] > 0) { echo "Return Code: " . $_FILES["upload"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["upload"]["name"] . "<br />"; echo "Type: " . $_FILES["upload"]["type"] . "<br />"; echo "Size: " . ($_FILES["upload"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["upload"]["tmp_name"] . "<br />"; $dir_exists = is_dir("/disks/*/*/*/*/". $_SESSION["FirstName"] ."-".$_SESSION["username"]."/"); $file_exists = file_exists("/disks/*/*/*/*/".$_SESSION["FirstName"] ."-".$_SESSION["username"]."/" . $_FILES["upload"]["name"]); $folderName=$_SESSION["FirstName"]; $baseDir = "/disks/*/*/*/*/"; // Create directory if it does not exist if (! $dir_exists) { if (is_writable($baseDir)) { mkdir($baseDir . $_SESSION["FirstName"]."-".$_SESSION["username"]); } else { trigger_error($baseDir. " is not writeable"); } } if ($file_exists) { echo $_FILES["upload"]["name"] . " already exists. "; } else { $link = new PDO('mysql:host=***;dbname=***;charset=UTF-8','***','***'); $proptype = $_POST["prop_cat"]; $stmt = $link->prepare("UPDATE Table SET `PType`=:proptype WHERE Username=:username"); $stmt->bindParam(':username', $username); $stmt->bindParam(':proptype', $proptype); $stmt->execute(); move_uploaded_file($_FILES["upload"]["tmp_name"], $baseDir. $_SESSION["FirstName"] ."-".$_SESSION["username"]."/". $_FILES["upload"]["name"]); echo "Stored in: " . $baseDir. $_SESSION["FirstName"] ."-".$_SESSION["username"]."/". $_FILES["upload"]["name"]; } } } else { echo "Invalid file"; }?>\[/code\]So basically to sum up my question: How can I hide the iframe until upload finishes, and then display it with the message that the user can close like an alert box?
 
Back
Top