Wrox Programmer Forums
|
Classic ASP Professional For 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 2nd, 2012, 08:01 AM
Authorized User
 
Join Date: Mar 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default upload ftp

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

%>
thanks
 
Old March 4th, 2012, 06:10 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

razstec

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:

ASP pure script upload
__________________
Wind is your friend
Matt
 
Old March 5th, 2012, 05:22 AM
Authorized User
 
Join Date: Mar 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, thanks for the reply.

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.

thanks
Ricardo
 
Old March 5th, 2012, 06:09 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

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?
__________________
Wind is your friend
Matt
 
Old March 6th, 2012, 05:04 AM
Authorized User
 
Join Date: Mar 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, im trying to use this script

http://benmeg.com/code/asp/ftp.asp.html

but cant seem to make it work.

thanks
 
Old March 6th, 2012, 05:25 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

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?
__________________
Wind is your friend
Matt

Last edited by mat41; March 6th, 2012 at 05:27 PM..
 
Old March 7th, 2012, 05:05 AM
Authorized User
 
Join Date: Mar 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually im trying with windows server 2008...

If i manage to get it working i will post it here, if you get any ideia please let me know my deadline for this is friday :s
 
Old March 7th, 2012, 06:04 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

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....
__________________
Wind is your friend
Matt
 
Old March 8th, 2012, 05:13 AM
Authorized User
 
Join Date: Mar 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Im going to take a look at dundas since they are giving the componnent for free, the problem is testing my hosting service dont have it.





Similar Threads
Thread Thread Starter Forum Replies Last Post
FTP Upload in ASCII David_0223 C# 1 August 20th, 2008 10:56 AM
ftp file upload yugi9966 ADO.NET 1 August 7th, 2008 09:09 AM
ftp upload using PORT mode rcverbeek C# 2005 0 June 13th, 2007 06:43 AM
FTP Upload from Excel 2003 VBA Jersey Eric Excel VBA 3 January 5th, 2006 09:29 AM
Upload Of Excel file to FTP Site shahbazr4 Java Databases 0 May 2nd, 2005 04:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.