echo "\n".'</script></body></html>'; exit(); } function safehtml($s) { $s=str_replace("&", "&", $s); $s=str_replace("<", "<", $s); $s=str_replace(">", ">", $s); $s=str_replace("'", "'", $s); $s=str_replace("\"", """, $s); return $s; } if (isset($_POST['description'])) { $filename = $_POST['filename']; $size = filesize($upload_dir.'/'.$filename); $date = date('r', filemtime($upload_dir.'/'.$filename)); $description = safehtml($_POST['description']); $html =<<<END <html><head><title>{$filename} [uploaded by IFRAME Async file uploader]</title></head> <body> <h1>{$filename}</h1> <p>This is a file information page for your uploaded file. Bookmark it, or send to anyone...</p> <p>Date: {$date}</p> <p>Size: {$size} bytes</p> <p>Description: <pre>{$description}</pre> </p> <p><a href="{$web_upload_dir}/{$filename}" style="font-size: large;">download file</a><br> <a href="{$PHP_SELF}" style="font-size: small;">back to file uploading</a><br> <a href="{$web_upload_dir}/upload-log.html" style="font-size: small;">upload-log</a></p> <br><br>Example by <a href="http://www.anyexample.com/">AnyExample</a> </body></html> END; $f = fopen($upload_dir.'/'.$filename.'-desc.html', "w"); fwrite($f, $html); fclose($f); $msg = "File {$filename} uploaded, <a href='{$web_upload_dir}/{$filename}-desc.html'>see file information page</a>"; $f = fopen($upload_dir."/upload-log.html", "a"); fwrite($f, "<p>$msg</p>\n"); fclose($f); setcookie('msg', $msg); header("Location: http://".$_SERVER['HTTP_HOST'].$PHP_SELF); exit(); } if (isset($_COOKIE['msg']) && $_COOKIE['msg'] != '') { if (get_magic_quotes_gpc()) $msg = stripslashes($_COOKIE['msg']); else $msg = $_COOKIE['msg']; setcookie('msg', ''); } ?> <!-- Beginning of main page --> <html><head> <title>IFRAME Async file uploader example</title> </head> <body> <?php if (isset($msg)) echo '<p style="font-weight: bold;">'.$msg.'</p>'; ?> <h1>Upload file:</h1> <p>File will begin to upload just after selection. </p> <p>You may write file description, while you file is being uploaded.</p> <form action="<?=$PHP_SELF?>" target="upload_iframe" method="post" enctype="multipart/form-data"> <input type="hidden" name="fileframe" value="true"> <!-- Target of the form is set to hidden iframe --> <!-- From will send its post data to fileframe section of this PHP script (see above) --> |