העלאת קבצים ללא קומפוננטה

roee

New member
העלאת קבצים ללא קומפוננטה

השיטה האולטימטיבית. ללא קומפוננטות. ללא הגבלת קבצים
<%@ Language=VBScript %> <% ' FTP via ASP without using 3rd-party components ' Ben Meghreblian 15th Jan 2002 ' benmeg at benmeg dot com / http://benmeg.com ' ' This script assumes the file to be FTP'ed is in the same directory as this script. ' It should be obvious how to change this (*hint* change the lcd line) ' You may specify a wildcard in ftp_files_to_put (e.g. *.txt) Dim objFSO, objTextFile, oScript, oScriptNet, oFileSys, oFile, strCMD, strTempFile, strCommandResult Dim ftp_address, ftp_username, ftp_password, ftp_physical_path, ftp_files_to_put ' Edit these variables to match your specifications ftp_address = "ftp.server.com" ftp_username = "username" ftp_password = "password" ftp_remote_directory = "subdirectory" ' Leave blank if uploading to root directory ftp_files_to_put = "file.txt" On Error Resume Next Set oScript = Server.CreateObject("WSCRIPT.SHELL") Set oFileSys = Server.CreateObject("Scripting.FileSystemObject") Set objFSO = CreateObject("Scripting.FileSystemObject") ' Build our ftp-commands file Set objTextFile = objFSO.CreateTextFile(Server.MapPath("test.ftp")) objTextFile.WriteLine "lcd " & Server.MapPath(".") objTextFile.WriteLine "open " & ftp_address objTextFile.WriteLine ftp_username objTextFile.WriteLine ftp_password ' Check to see if we need to issue a 'cd' command If ftp_remote_directory <> "" Then objTextFile.WriteLine "cd " & ftp_remote_directory End If objTextFile.WriteLine "prompt" ' If the file(s) is/are binary (i.e. .jpg, .mdb, etc..), uncomment the following line' objTextFile.WriteLine "binary" ' If there are multiple files to put, we need to use the command 'mput', instead of 'put' If Instr(1, ftp_files_to_put, "*",1) Then objTextFile.WriteLine "mput " & ftp_files_to_put Else objTextFile.WriteLine "put " & ftp_files_to_put End If objTextFile.WriteLine "bye" objTextFile.Close Set objTextFile = Nothing ' Use cmd.exe to run ftp.exe, parsing our newly created command file strCMD = "ftp.exe -s:" & Server.MapPath("test.ftp") strTempFile = "C:\" & oFileSys.GetTempName( ) ' Pipe output from cmd.exe to a temporary file (Not :| Steve) Call oScript.Run ("cmd.exe /c " & strCMD & " > " & strTempFile, 0, True) Set oFile = oFileSys.OpenTextFile (strTempFile, 1, False, 0) On Error Resume Next ' Grab output from temporary file strCommandResult = Server.HTMLEncode( oFile.ReadAll ) oFile.Close ' Delete the temporary & ftp-command files Call oFileSys.DeleteFile( strTempFile, True ) Call objFSO.DeleteFile( Server.MapPath("test.ftp"), True ) Set oFileSys = Nothing Set objFSO = Nothing ' Print result of FTP session to screen Response.Write( Replace( strCommandResult, vbCrLf, "<br>", 1, -1, 1) ) %>​
 

roee

New member
כי ../images/Emo6.gif

פורום ASP נועד לעזור למפתחים הנתקלים בבעיות בזמן הפיתוח. זהו אינו המקום לחיפוש ובקשת קודים מוכנים
 

Admini

New member
אהבתי !

מה שמאפשר לי להמיר את זה בחמש דקות לדוט נט
 

roee

New member
הורד לעצמך גירסת ניסיון

למשתמשי NT 2000 וXP הקוד| IE3 http://www.skyzyx.com/downloads/ie3_nt.zip IE4 http://www.skyzyx.com/downloads/ie401_nt.zip IE5 http://www.skyzyx.com/downloads/ie501sp2_nt.zip IE5.5 http://www.skyzyx.com/downloads/ie55sp2_nt.zip|
 

gilad g

New member
למה לך?

בדוט נט יש תמיכה מובנית בזה (<input type=file runat=server>).
 

gilad g

New member
מה הקשר?

הוא דיבר על זה שהוא רוצה לממש את זה בדוט נט...
 

roee

New member
דווקא זהניראה לי עדיף על הפיתרון

של הNET. אין בעיית הרשאות . יש גמישות מקסימלית. בשביל להעביר קבצים עדיף FTP על HTTP. מצד שני - אין לי כ"כ הרבה נסיון בNET בשביל להשוות .
 
למעלה