An ASP version of the picture browser (and killer)

zhaozj2021-02-11  155

This is my first translation article, inadequate, please forgive me. India, now the reason why it has become a big software export, there are many places better than us. One of the primary advantages is that India's official language is English, which brings a unique advantage for Indian programmers as programming languages. For those who are engaged in IT industry, they should also strengthen their own English training. First, I would like to thank 9CBS to provide such a platform. Nothing to gossip, the text is as follows:

Introduction If you have a website that has been running two months, you may notice that you have accumulated a lot of pictures on your website. Although we have tried our best to naming these picture files, we will always hardly think of some of the picture file names or use when we go to the file name of these images. At this time, we usually use the browser to open those pictures with your browser. What is the picture? At this time, this ASP code can be used as a picture browser (and cleaning) to browse these pictures and perform cleanup operations.

Encoding: In fact, this program is a list page containing all images in a directory. Use the FileSystemObject object to list these image files (GIF and JPEG files). Add a link to Toggle Display to control whether the image is displayed. When you have a lot of files, don't want to load them, you can only display a picture of the page, reverse, if you are not sure that some file naming is meaning, this feature will help you clean up. Here is a very simple code <% @ language = vbscript%> <% option explicit%> <% const imagefilepath = "images" const deletebuttonLabel = "delete successd images"

DIM Objfsodim ObjfolderDim objfile

DIM STRFILENAMEDIM STRFILEXTENSIM STRFILEEXTENSIM STRFILEEXTENSIM STRFILEEXTENSIM

DIM BLNSHOWIMAGES

If Request.QueryString ("Showimages") = "" "" "")) Endiff (Request.QueryString ("showimages)) endiffs

If Request.form ("btndelete") = deleteButtonLabel Then set objfso = Server.createObject ("scripting.filesystemobject")

For Each Strfilename in Request.form ("delete") objfso.deletefile (server.mappath (imagefilepath & ") Next @ mf mf

Set objfso = not%> ASP 101 Image Browser & killer! </ Title> </ head> <body></p> <p><form action = "<% = Request.ServerVariables (" URL ")%>" Method = "POST"></p> <p><Table Border = "1"> <TR> <TH> Image Name </ TH> <TH> Image <a href="<%= Request.ServerVariables ("url")% ShowImages = <% = NOT BLNSHOWIMAGES %> "> (TOGGLE DISPLAY) </A> </ th> <TH> Delete this image </ t> </ tr> <% set objfso = server.createObject (" scripting.filesystemObject ") set objfolder = objfso. GetFolder (server.mappath) for each objfile in objfolder.files strfileExtension = lcase (mid (objfile.name, _ instrib (objfile.name, ".", -1, 1) 1))</p> <p>If strFileExtension = "gif" Or strFileExtension = "jpg" Or _ strFileExtension = "jpeg" Then 'Original image file identification option:' If objFile.Type = "GIF Image" Or _ objFile.Type = "JPEG Image" Then%> <tr> <TD> <a href="<%= imagefilepath & "" ojLE.NAME%> <% = objfile.name%> </a> </ td> <% if blnshowimages the%> <TD> <IMG SRC = "<IMAGEPATH &" / "& objfile.name%>" /> <TD> <% else%> <TD> <a href = "<= imagefilepath &" / " & objfile.name%>>> View image </a> </ td> <% end if%> <TD align = "center"> <input type = "checkbox" name = "delete" value = "<% = Objfile.name%> "/> </ td> <% end ifnextset Objfolder = NothingSet Objfso = Nothing%> <Tr> <TD colspan =" 3 "align =" right "> <input type =" Submit "Name =" Btndelete "Value =" <% = deletebuttonlabel%>> </ td> </ tr> </ table></p> <p></ form></p> <p></ body> </ html></p> <p>Be sure to pay attention to the delete operation, if you do not delete a confirmation prompt in the program, the program will not undo the deletion.</p> <p>Conclusion People always take ASP to build large-scale upgraded websites. (Translator Note: This sentence is not very appropriate. According to my work experience, ASP can build a large website system. In ASP, I have participated in the construction of large-scale enterprises, mobile industry applications.) But sometimes you can simplify your work, even if this code is not published on the Web. Get the code You can download the ZIP file containing this code http://www.asp101.com/articles/john/imageviewer/imgview.zip. In order to control the size of the file, I don't include an image example. I will remind you again, use this code to do damage and delete a lot of related pictures is easy. Note that when you don't delete a confirmation, you have to confirm that you have used the image to operate.</p> <p>The code update I have received a lot of email about this code. After reading, I still found a lot of problems. First: Some people don't realize that they must set up the code to find the path. I have now set a picture directory in the directory of the code. So, if I put the code in the root of http://www.weiw.com, the code will be executed, and http: //www.weiw will be displayed. All pictures under COM / images. You can change the value of ImageFilePath constants. You can also put some virtual path here, the code will use server.mappath to determine the appropriate physical path. You can easily specify some locations on your website. For example, change the value of that constant from "images" to "/ images" so that the program will point to the image of the IMAGES directory of the website. Similarly, you can modify the value of ImageFilePath to achieve the same purpose.</p> <p>Second: When writing this code, I simply use the file type in my machine. This can only run smoothly on my machine. Therefore, it is found that the description of the file type can change your file. In order to get your choice to display those extensions based on such files instead of their type. I have implemented this feature in the code in this ZIP file. Now this is the latest program version. http://www.asp101.com/articles/john/imageviewer/imgview.zip</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-5609.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="5609" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.043</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = '4gVY9NXDLHvriB_2BLmAKnIdmNxSf09j0288m3J6Z3ja9tNcoJpD_2FssdlvO3me_2BlmlhPqfOwXYZutb9q6_2FXkLMmg_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>