Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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 .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 2nd, 2012, 07:01 AM
Registered User
Points: 28, Level: 1
Points: 28, Level: 1 Points: 28, Level: 1 Points: 28, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 8
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
Reply With Quote
  #2 (permalink)  
Old March 4th, 2012, 05:10 PM
Friend of Wrox
Points: 6,378, Level: 34
Points: 6,378, Level: 34 Points: 6,378, Level: 34 Points: 6,378, Level: 34
Activity: 28%
Activity: 28% Activity: 28% Activity: 28%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,822
Thanks: 12
Thanked 14 Times in 14 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
Reply With Quote
  #3 (permalink)  
Old March 5th, 2012, 04:22 AM
Registered User
Points: 28, Level: 1
Points: 28, Level: 1 Points: 28, Level: 1 Points: 28, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 8
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
Reply With Quote
  #4 (permalink)  
Old March 5th, 2012, 05:09 PM
Friend of Wrox
Points: 6,378, Level: 34
Points: 6,378, Level: 34 Points: 6,378, Level: 34 Points: 6,378, Level: 34
Activity: 28%
Activity: 28% Activity: 28% Activity: 28%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,822
Thanks: 12
Thanked 14 Times in 14 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
Reply With Quote
  #5 (permalink)  
Old March 6th, 2012, 04:04 AM
Registered User
Points: 28, Level: 1
Points: 28, Level: 1 Points: 28, Level: 1 Points: 28, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 8
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
Reply With Quote
  #6 (permalink)  
Old March 6th, 2012, 04:25 PM
Friend of Wrox
Points: 6,378, Level: 34
Points: 6,378, Level: 34 Points: 6,378, Level: 34 Points: 6,378, Level: 34
Activity: 28%
Activity: 28% Activity: 28% Activity: 28%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,822
Thanks: 12
Thanked 14 Times in 14 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 04:27 PM.
Reply With Quote
  #7 (permalink)  
Old March 7th, 2012, 04:05 AM
Registered User
Points: 28, Level: 1
Points: 28, Level: 1 Points: 28, Level: 1 Points: 28, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 8
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
Reply With Quote
  #8 (permalink)  
Old March 7th, 2012, 05:04 PM
Friend of Wrox
Points: 6,378, Level: 34
Points: 6,378, Level: 34 Points: 6,378, Level: 34 Points: 6,378, Level: 34
Activity: 28%
Activity: 28% Activity: 28% Activity: 28%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,822
Thanks: 12
Thanked 14 Times in 14 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
Reply With Quote
  #9 (permalink)  
Old March 8th, 2012, 04:13 AM
Registered User
Points: 28, Level: 1
Points: 28, Level: 1 Points: 28, Level: 1 Points: 28, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 8
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.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 08:29 AM
Upload Of Excel file to FTP Site shahbazr4 Java Databases 0 May 2nd, 2005 04:01 AM



All times are GMT -4. The time now is 06:49 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.