Classic ASP ProfessionalFor advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
Hi all, im trying to set an ftp upload but im having some problems, i have several response.write and all are printed in the page, there is no error in log but it dont do nothing, anyone can help?
Code:
<%@ Language=VBScript %>
<%
ftp_address = "78.79.23.45"
ftp_username = "cork"
ftp_password = "1234"
ftp_remote_directory = ""
ftp_files_to_put = ""
Dim objFSO, objTextFile, oScript, oScriptNet, oFileSys, oFile, strCMD, strTempFile, strCommandResult
Dim ftp_address, ftp_username, ftp_password, ftp_physical_path, ftp_files_to_put, campo1, campo2, campo3, campo4, campo5, campo6
' Recupera os Dados ----------------------
'study = Request.Form("study")
'centro = Request.Form("centro")
ficheiross = Request.Form("ficheiro")
hora=time()
data= date()
utl= Session("user")
response.write "222222222222222222222222222222222222222222222<br><br>"
' pasta + nome dos arquivos
cficheiro = ftp_remote_directory + ficheiross
response.write (""&cficheiro&"<br><br>")
' Faz o Upload do arquivo selecionado
response.write "33333333333333333333333333333333333333333333333333333333333333333<br><br>"
On Error Resume Next
Set oScript = Server.CreateObject("WSCRIPT.SHELL")
Set oFileSys = Server.CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")
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
'Verifique para ver se precisamos emitir uma' cd 'command
If ftp_remote_directory <> "" Then
objTextFile.WriteLine "cd " & ftp_remote_directory
End If
objTextFile.WriteLine "prompt"
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
'Cmd.exe Use para executar ftp.exe, parsing comando arquivo recém-criado
strCMD = "ftp.exe -s:" & Server.MapPath("test.ftp")
strTempFile = "C:\" & oFileSys.GetTempName( )
'saída de cmd.exe para um arquivo temporário
Call oScript.Run ("cmd.exe /c " & strCMD & " > " & strTempFile, 0, True)
Set oFile = oFileSys.OpenTextFile (strTempFile, 1, False, 0)
On Error Resume Next
'Pega a saída do arquivo temporário
strCommandResult = Server.HTMLEncode( oFile.ReadAll )
oFile.Close
'Eliminar os temporários e os arquivos ftp-comando
Call oFileSys.DeleteFile( strTempFile, True )
Call objFSO.DeleteFile( Server.MapPath("test.ftp"), True )
Set oFileSys = Nothing
Set objFSO = Nothing
'Mostra o resultado da sessão de FTP para a tela
Response.Write( Replace( strCommandResult, vbCrLf, "<br>", 1, -1, 1) )
response.write "4444444444444444444444444444444444444444444444444444444444444444444444444<br><br>"
'insere os dados na base de dados
'instotal = "Insert into ficheiros (nome_study,centro,ficheiro,data_in, username, hora_in) values ('"& study &"', '"& centro &"', '"& cficheiro &"','"& 'data&"', '"& utl&"', '"& hora&"')"
'rs.open instotal,conn,2,2
' Redireciona
response.write "o ficheiro com o nome " Request.Form("ficheiro") " foi enviado com sucesso."
'response.redirect ("addfiles.asp?erro=File uploaded sucessfully")
call gonow
%>
Not a very good post.....if you want help and other peoples time you need to learn how best to use forums. Posting a whole page of code just saying its not working will not get you very far...in fact probably nowhere.....
You need to be much more specific about your issues, only post the problematic code, including the error and line number if possible. This way you give the impression you have done all you can to help yourself before asking others. Forums are not about other writing code for you, they are to get help with specific issues.
Have a look at Imars solution here for a pure ASP upload, it works very well:
I know but like i said the page runs and presents all response.write but it dont do the upload and dont even show any error, thats why i put the all page, because i dont know where the problem is and maybe someone could notice what was wrong.
Thansk for the link but im trying to do a ftp upload for file up to 500mb the http upload wont work.
I am not experienced setting up FTP however I do not believe its possible using a .asp page and Classic ASP's File System Object. I could be wrong, when you research this are you reading that its possible?
Interesting....I can see how reading that may give the impression your objective is possible. have you read anywhere that its truly using the FTP protocol and that there is no file size restriction?
have you tried it with a small file?
I am interested in looking at this and will have a play however I cant see me having time today. I will let you know what my outcome is. in the mean time if you get it going/solve your issue make sure to post...
OH BTW as the link says it may not work in versions of IIS 6.0+ What OS/IIS version are you using. As it suggests it should work with XP and IIS 6.0, i assume you have read this and are trying with XP?
based on the comments by the author its not going to work in the 2008 environment. You have read these comments I assume? I think you need an alternate solution....