Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 10 total
Thread Uploading a File
Tue, May 15 2012 8:55 AMPermanent Link

Mark Brooks

Slikware

Avatar

Hi All,

I have a requirement for the user of my application to:

a) Select a local file

b) Upload it to a URL

Can anybody provide some advice as to where I might start looking in order to implement these two chunks of functionality?

Thanks
Mark
Tue, May 15 2012 9:08 AMPermanent Link

Rick

<Mark Brooks> wrote in message
news:D4556B97-D201-4904-8C41-1FC662873FFB@news.elevatesoft.com...
>
> I have a requirement for the user of my application to:
>
> a) Select a local file
>
> b) Upload it to a URL
>
> Can anybody provide some advice as to where I might start looking in order
> to implement these two chunks of functionality?
>
>

Hi Mark.

You could try using a TServerRequest with rmPost to simulate a html form
(see the EWB FAQ for an example) and specify input type="file". You would
need to write a php script on your server to receive the file.

Have a look at http://w3schools.com/php/php_file_upload.asp for an example
of this process.

--
Rick

Tue, May 15 2012 9:19 AMPermanent Link

Mark Brooks

Slikware

Avatar

"Rick" wrote:

<Mark Brooks> wrote in message
news:D4556B97-D201-4904-8C41-1FC662873FFB@news.elevatesoft.com...
>
> I have a requirement for the user of my application to:
>
> a) Select a local file
>
> b) Upload it to a URL
>
> Can anybody provide some advice as to where I might start looking in order
> to implement these two chunks of functionality?
>
>

Hi Mark.

You could try using a TServerRequest with rmPost to simulate a html form
(see the EWB FAQ for an example) and specify input type="file". You would
need to write a php script on your server to receive the file.

Have a look at http://w3schools.com/php/php_file_upload.asp for an example
of this process.

--
Rick

Ok Rick,

I'll give it a try, but how do I specify input type='file'?

Thanks

Mark
Tue, May 15 2012 9:19 AMPermanent Link

Mark Brooks

Slikware

Avatar

"Rick" wrote:

<Mark Brooks> wrote in message
news:D4556B97-D201-4904-8C41-1FC662873FFB@news.elevatesoft.com...
>
> I have a requirement for the user of my application to:
>
> a) Select a local file
>
> b) Upload it to a URL
>
> Can anybody provide some advice as to where I might start looking in order
> to implement these two chunks of functionality?
>
>

Hi Mark.

You could try using a TServerRequest with rmPost to simulate a html form
(see the EWB FAQ for an example) and specify input type="file". You would
need to write a php script on your server to receive the file.

Have a look at http://w3schools.com/php/php_file_upload.asp for an example
of this process.

--
Rick

Ok Rick,

I'll give it a try, but how do I specify input type='file'?

Thanks

Mark
Tue, May 15 2012 9:20 AMPermanent Link

Mark Brooks

Slikware

Avatar

"Rick" wrote:

<Mark Brooks> wrote in message
news:D4556B97-D201-4904-8C41-1FC662873FFB@news.elevatesoft.com...
>
> I have a requirement for the user of my application to:
>
> a) Select a local file
>
> b) Upload it to a URL
>
> Can anybody provide some advice as to where I might start looking in order
> to implement these two chunks of functionality?
>
>

Hi Mark.

You could try using a TServerRequest with rmPost to simulate a html form
(see the EWB FAQ for an example) and specify input type="file". You would
need to write a php script on your server to receive the file.

Have a look at http://w3schools.com/php/php_file_upload.asp for an example
of this process.

--
Rick

Ok Rick,

I'll give it a try, but how do I specify input type='file'?

Thanks

Mark
Tue, May 15 2012 10:38 AMPermanent Link

Rick

<Mark Brooks> wrote in message
news:9796667A-70B4-4A99-AE10-281E58E89A7D@news.elevatesoft.com...
>
>
> I'll give it a try, but how do I specify input type='file'?
>
>

Mark, there's probably a way to inject form elements such as file type into
the DOM but until the EWB documentation is released it's not too clear.

One solution I found is to use the TPage control.

Create two files on your server: upload_file.htm and upload_file.php.

upload_file.htm consists of the html taken from
http://w3schools.com/php/php_file_upload.asp
upload_file.php consists of the php script also taken from
http://w3schools.com/php/php_file_upload.asp

Drop the TPage control onto your EWB form and point the URL property at the
upload_file.htm file on your server. When you run the EWB application you
should see the file upload request form displayed along with browse and
submit buttons. Click browse to select the local file you want to upload.

Not a perfect solution but should do the job for now.

--
Rick

Tue, May 15 2012 12:29 PMPermanent Link

Mark Brooks

Slikware

Avatar

>>Mark, there's probably a way to inject form elements such as file type into
>>the DOM but until the EWB documentation is released it's not too clear.

I agree that's the ideal way. TElement does have a setAttribute method and I have used this and applied it to an EWB TButton (setting type='file') to get it to display the file picker. However I cannot work out how to perform the subsequent submit via another button because my HTML skills are weak. I think it needs a form wrapper and it's not obvious to me how to create that.

>>One solution I found is to use the TPage control.

This works to a degree. I have created some HTML that will display a button and file picker. The problem is that TPage uses an iFrame and so I cannot get to the form with it in order to execute the submit from another button.

>>Not a perfect solution but should do the job for now.

Still not quite there! Very frustrating because the file upload is my final hurdle to overcome. EWB has handled everything else I've thrown at it with aplomb.

Tim - Can you chip in with a beautifully elegant solution that I'm missing and that "just works" ...... Smile

Mark
Wed, May 16 2012 1:10 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mark,

<< Tim - Can you chip in with a beautifully elegant solution that I'm
missing and that "just works" ...... Smile>>

I already responded via email about this - yes, I can add a file upload
button.  The problem is that I still need a way to allow you to submit such
a file selection, so I'll have to think about this further.

Tim Young
Elevate Software
www.elevatesoft.com
Wed, May 16 2012 4:46 PMPermanent Link

Mark Brooks

Slikware

Avatar

>>"Tim Young [Elevate Software]" wrote:

>>I already responded via email about this - yes, I can add a file upload
>>button.  The problem is that I still need a way to allow you to submit such
>>a file selection, so I'll have to think about this further.

Sorry Tim. That email has not arrived. A file-upload button is an absolute must IMHO. The upload capability in general completes EWB as a great "REST client creator". I have managed to kludge something together and will post the code tomorrow just in case it helps. It's ugly as hell and uses a tip from Rick plus a bit of DOM fiddling.

Cheers
Mark
Thu, May 17 2012 1:14 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mark,

<< Sorry Tim. That email has not arrived. >>

Has it arrived yet ?  I didn't get a bounce notification on my end.  (btw,
the comment about the email was just a heads-up, not a complaint Smile).

<< A file-upload button is an absolute must IMHO. The upload capability in
general completes EWB as a great "REST client creator". I have managed to
kludge something together and will post the code tomorrow just in case it
helps. It's ugly as hell and uses a tip from Rick plus a bit of DOM
fiddling. >>

Yes, you definitely have to do some weird stuff to get it to work correctly.
What I'll be adding is a simple button that will allow you to click, select
a file, and then have the file uploaded *immediately* to the back-end.
Then, then back-end can use that information to display the file as part of
a list for selection, etc.

If you have any other questions, please let me know.

Tim Young
Elevate Software
www.elevatesoft.com
Image