Groups | Blog | Home
all groups > iis ftp > december 2006 >

iis ftp : Getting String Version Of File For FTP - Not Actual File


pbd22
12/10/2006 3:07:35 PM
hi.

(If you want to skip the verbage (although you will need some), go to
the below "THE QUESTION".)

i am new to this... i am trying to upload a file without using the MS
provided asp:fileupload control.
i am using a javascript multiple file upload script what creates hidden
input type=file boxes with
each additional file:

the blog on this script is here:
http://the-stickman.com/web-development/javascript/upload-multiple-files-with-a-single-file-element/

and the hidden input's look like this once the user has added a bunch
of files:

<input name="video_6" type="file"><input style="position: absolute;
left: -1000px;" name="video_5" type="file"><input style="position:
absolute; left: -1000px;" name="video_4" type="file"><input
style="position: absolute; left: -1000px;" name="video_3"
type="file"><input style="position: absolute; left: -1000px;"
name="video_2" type="file"><input style="position: absolute; left:
-1000px;" name="video_1" type="file"><input style="position: absolute;
left: -1000px;" id="my_file_element" name="video_0" type="file"><input
type="submit">

i am doing this b/c i am trying to get the process to be as easy as
possible for the user - at least
the "appearance" of no trip to the server even if this is acheived via
a hidden iframe to upload.

OK, MY PROBLEM:

my problem is that i dont really understand how to pass the uploaded
file from the user's computer to the server for upload. when i try to
upload, the script fails with:

"The file: somefile.gif was not found. Can not upload the file to the
FTP Site."

this is because it is reading the file as a "string" and looking for it
in a local directory. Not the actual byte-by-byte file offered by the
user. In the below code, you can see that i am trying to grab a saved
file using Request.Params.Get("video_1") and pass it to the clsFTP
class using: ftpClient.UploadFile(params).

if you want to see how my server code works, here is a link to that (MS
- provided) class:
http://www.dotnethero.com/hero/vbnet/ftp.aspx?nmx=8_4

THE QUESTION:

How do i pass the the "actual file", and not a string version of the
file, to the server for upload?

THE ONCLICK CODE:

Public Sub Upload(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Upload_ServerClick.Click

Dim ftpClient As New Code.clsFTP("aria", "", "anonymous",
Context.User.Identity.Name, 80)

If (ftpClient.Login() = True) Then
'Create a new folder
ftpClient.CreateDirectory("FTPFOLDERNEW")

'Set our new folder as our active directory
ftpClient.ChangeDirectory("FTPFOLDERNEW")

'Set FTP mode
ftpClient.SetBinaryMode(True)

dim params as String = Request.Params.Get("video_1")

'Upload a file from your local hard disk to the FTP site.
ftpClient.UploadFile(params)

'Always close the connection to make sure that there are
not any not-in-use FTP connections.
'Check to see if you are logged on to the FTP server and
then close the connection.
ftpClient.CloseConnection()

End If

THE UPLOAD HTML:

I am also confused as to what scripts i should be adding for the
actions of from and iframe.
is this the same as the code for my Upload_Click event? I know, i am
confused. Thanks for the help tho :).

<tr>
<td colspan=3>
<form action="?" enctype="multipart/form-data" method="post"
target="targetupload">
<input id="my_file_element" type="file" name="file_1" /><input
type=submit />
</form>
<iframe id='targetupload' name='targetupload'
style="width:0px;height:0px" scrolling="auto" frameborder="0"
height="0" src="?">
</iframe>
</td>
</tr>
pbd22
12/10/2006 6:37:34 PM

Hi Again,

I have updated this code a bit. It still isnt working but, if there is
somebody out there
that really knows his/her stuff with regards to IIS, ASP.NET, and ftp
using a RPC via
a hidden iframe, i'd appreciate it if i could send you my form(s) to
have a look. I think
i am a bit over my head at this point.

Thanks again for all your help.



[quoted text, click to view]
AddThis Social Bookmark Button