Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP iFrame Upload Confirmation
    primarykey
    data
    text
    <p>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:</p> <pre><code>&lt;iframe class="iframe" name="my_iframe" src="upload_file.php" style="display:none;"&gt;&lt;/iframe&gt; &lt;form id="uploadForm" action="upload_file.php" method="post" enctype="multipart/form-data" target="my_iframe"&gt; </code></pre> <p>So basically I want to hide my iframe <em>UNTIL</em> I the upload process finishes and the script returns a message. Here's my php script:</p> <pre><code>&lt;?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"] &lt; 200000) &amp;&amp; in_array($extension, $allowedExts)) { if ($_FILES["upload"]["error"] &gt; 0) { echo "Return Code: " . $_FILES["upload"]["error"] . "&lt;br /&gt;"; } else { echo "Upload: " . $_FILES["upload"]["name"] . "&lt;br /&gt;"; echo "Type: " . $_FILES["upload"]["type"] . "&lt;br /&gt;"; echo "Size: " . ($_FILES["upload"]["size"] / 1024) . " Kb&lt;br /&gt;"; echo "Temp file: " . $_FILES["upload"]["tmp_name"] . "&lt;br /&gt;"; $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-&gt;prepare("UPDATE Table SET `PType`=:proptype WHERE Username=:username"); $stmt-&gt;bindParam(':username', $username); $stmt-&gt;bindParam(':proptype', $proptype); $stmt-&gt;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"; } ?&gt; </code></pre> <p>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?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload