رمز المبدأ:
strfilename = request.querystring ("file1") تعيين OBJStream = server.createBject ("Adodb.stream") objstream.type = 1 'adtypebinary objstream.Open objstream.loadfromfile strfilename objstream.savetofile server.mappath ("123_onweb.gif") ، 2 |
كيفية استخدام:
اكتب الرمز أعلاه باسم التحميل. asp
يدخل:
http: //xxx/upload.asp؟ file1 = c:/upload file/123.gif
xxx هو عنوان المضيف الخاص بك
بعد التنفيذ ، سترى أن هناك 123_onweb.gif إضافية في الدليل الخاص بك
إنه ما تريده الملف
وفقًا للمبدأ ، يمكننا تمديد الرمز التالي:
ملف upload.htm
<form name = "form" action = "upload.asp" method = "post"> <إدخال type = "file" name = "file1" value = ""> <إدخال type = "إرسال" name = "إرسال" value = "OK"> </form> |
ملف upload.asp
<٪ وظيفة getFilename (Byval Strfile) إذا strfile <> "" ثم getFilename = Mid (strfile ، instrev (strfile ، "/")+1) آخر getFilename = "" إنهاء إذا وظيفة نهاية strfilename = request.form ("file1") تعيين OBJStream = server.createBject ("Adodb.stream") objstream.type = 1 'adtypebinary objstream.Open objstream.loadfromfile strfilename objstream.savetofile server.mappath (getFilename (strfilename)) ، 2 objstream.close ٪> |
التصحيح المحلي ناجح ، لكن وضع C/S لا يمر!