This article mainly for you to introduce the PHP implementation of File Preview function, with a certain reference value, interested in small partners can refer to
The previous blog is the upload function, this post is uploaded picture preview and changes:
The code is as follows:
1.yulan.php
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
2.ylchuli.php
<?PHPIF ($_files["File" ["Error"]) { echo $_files["file"] ["Error"];} else{ if (($_files["file"] ["type"]== "Image/jpeg" | | $_files["FILE" ["Type"]== "Image/png") && $_files[" File "[" Size "]<1024000) { $fname ="./images/". Date (" Ymdhis "). $_files[" File "[" name "]; $filename = Iconv ("UTF-8", "gb2312", $fname); if (file_exists ($filename)) { echo "<script>alert (' the file already exists! ');</script> "; } else { move_uploaded_file ($_files["file"] ["Tmp_name"], $filename) ; $delurl = Iconv ("UTF-8", "gb2312", $_post["TP"]); Unlink ($delurl); Delete file echo "<script>parent.showimg (' {$fname} ');</script>";}} }