View Full Version : Upload with AMFPHP ?
fx.barrett
03-15-2009, 11:27 PM
Hi guys,
I'm trying to put together an application that uploads a file to the server using Flex and AMFPHP. The only upload apps I've done were using simple .php scripts and I'm a bit lost now.
I'm using a RemoteObject to communicate with the AMF side but here's the problem. With a normal .php script I would have used the upload(); method of the FileReference class to upload the file but I have absolutely no idea how to do the same thing with the help of a remote object. I was thinking about passing the FileReference object to a PHP method but I have no idea what to do next or if that's even helping.
How on earth can I send the desired file data to my PHP method using RemoteObjects so I can upload the file ? I've been surfing the net for a solution but with no luck...
Any suggestions are welcome. Thanks.
wvxvw
03-15-2009, 11:51 PM
If you can use FP10, then you can use FileReference.data property (after the user chooses the file it will contain the bytes of that file), but I don't think you can do this with FileReference in FP9...
fx.barrett
03-16-2009, 12:26 PM
So, there's no way I can send a file I select from my local HDD with FileReference to an AMFPHP method and save it to the server ( upload it ). That sucks hard... FP10 wouldn't be a problem since this is for personal use, but still, it sucks hard that I can't do it with FP9 + Flex + AMFPHP.
wvxvw
03-16-2009, 12:42 PM
No, I don't think you can since you have very little control over how FR is sending files... But if you can use AIR / Zinc (i.e. you don't need the client to be an online app), then, you can read the data into flash and then send it wherever you want.
fx.barrett
03-16-2009, 12:57 PM
But if you can use AIR / Zinc (i.e. you don't need the client to be an online app), then, you can read the data into flash and then send it wherever you want.
Yeah, I know but since I'll be sending E-mails afterward, I will still need a server-side scrip so I don't really see any point in using AIR just for that purpose. Obviously, I could uses SMTP or something instead a server-side script but that would be too much of a fuss for this tiny app and I prefer going the server-side way...
Anyway, thanks, I think I'll go for FP10.
wvxvw
03-16-2009, 04:05 PM
What I was refering to when I said that you can use AIR, is that it has File / FileStream classes, so, you could just open the file from file system, read it and then send as you want. But this is only in case you don't need the app to be embedded into HTML page...
live.in
04-26-2009, 05:14 PM
What I was refering to when I said that you can use AIR, is that it has File / FileStream classes, so, you could just open the file from file system, read it and then send as you want. But this is only in case you don't need the app to be embedded into HTML page...
Could explain me a bit of how can i use FileSream to upload file?, I'm building an AIR application using amfphp to upload multiple files. Thanks.
wvxvw
04-26-2009, 05:26 PM
http://www.actionscript.org/forums/showthread.php3?t=197606
This is something very simple I've wrote once to illustrate how you can send binary data from / to the server using AMF.
There's a great tutorial on this same issue here:
(Better use that than my example)
http://www.sephiroth.it/tutorials/flashPHP/amfphp_bytearray/
For the FileStream the mere copy-paste of the example given in the manual would suffice. But, if you like more complex examples, here's the one:
http://code.google.com/p/e4xu/source/browse/trunk/src/air-sources/MXMLBeautifier.mxml
live.in
04-26-2009, 05:47 PM
wvxvw, you reply was very fast.
I'm going to read the articles.
Thanks in advance.
:)
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.