Here is a simple Sample of Ajax upload using the HTML5 File API

frontend javascript
=================
$("fileupload").observe("change",handleupload);

function handleupload( e )
{
var el = e.findElement();
new
Ajax.Request("backend.php?uploadfile=1",{"method":"post","postBody":el.files[0],"onSuccess":returnupload});
}

backend.php
=====================
if(isset($_GET['uploadfile']))
{
$uploaded_file = file_get_contents("php://input");
file_put_contents("/tmp/myfilename",$uploaded_file);
}

=====================

You can also add other events to the Ajax call to see upload progress as
well, but again will not work with IE - works in Firefox/Chrome/Safari
though


Jason Westbrook | T: 313-799-3770 | jwestbr...@gmail.com



On Wed, May 16, 2012 at 11:48 AM, Marty Amberg <mar...@edenstreet.com>wrote:

>  Thanks Jason
>
> Will give it a shot.  A example would be great,
>
>
>
> On 5/13/2012 12:32 AM, Jason wrote:
>
>
>  Totally do-able using the HTML 5 Javascript File API (won't work in IE
> though)
>
>  you can use the file object in the postBody option and that will upload
> the file to your php script through the php://input stream - use $_GET
> parameters for the rest of the information you want to post
>
>
>  to solve the IE problem chromeframe is a good solution as well
>
>  I can post an example if you need
>
>  Jason
>
> On Sunday, April 22, 2012 4:54:45 PM UTC-7, nottobefound wrote:
>>
>> Hi all,
>>
>> Quick question.
>> I been trying to get a file to upload to  a server via a form ( works
>> great in straight html calling a php program ) using a  prototype ajax
>> request.  I  don't think it can be done and I have tried various
>> ways.    If I am wrong and  could some one point me in the right
>> directions.
>>
>> Thanks
>>
>>
>>
>>
>> --
>> EdenStreet Consulting
>> w:978-741-7518
>> c:978-821-1309
>> Twitter: martyateden
>> Skype: martyateden
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/prototype-scriptaculous/-/lcLPBMCW9dMJ.
> To post to this group, send email to
> prototype-scriptaculous@googlegroups.com.
> To unsubscribe from this group, send email to
> prototype-scriptaculous+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/prototype-scriptaculous?hl=en.
>
>
> --
> EdenStreet Consulting
> w:978-741-7518
> c:978-821-1309
> Twitter: martyateden
> Skype: martyateden
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To post to this group, send email to
> prototype-scriptaculous@googlegroups.com.
> To unsubscribe from this group, send email to
> prototype-scriptaculous+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/prototype-scriptaculous?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to