This content has been marked as final. Show 45 replies
and the php...
anyone know anything about this????
I don't know anything about it, sorry.
I know PHP 5.2.2 has problems with $GLOBALS["HTTP_RAW_POST_DATA"]
This wasn't a problem in 5.2.1 and is apparently fixed in 5.2.3. There are also simple workarounds posted if that's related.
I took a quick look at the link you posted. Firefox showed me the request for create.php returned a page not found response:
Perhaps that helps, perhaps not. Good luck.
i can see the page in firefox, however, I do receive this error
Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: create.php?name=snapshot.jpg
i made an application that worked fine using mario klingemann's bitmapexporter class:
the www.quasimondo.com is very slow and i tried it already. it uses as2.0 and sends the data over a connection usually giving the flash player is running slow click here to abort message.
i did find someone using it in as3.0 and used most of there code, however i couldn't even re-use their files to re-create their video capture.
mine is much simplier than a video screen shot. i just want to take a movie clip and save it's "screen shot" to a jpeg. as3.0 allows you to do this much faster.
there is the link of it in action. for screen shots of high quality it is very fast. i can make it save to the disk locally, but never save to the server?
Did you see my earlier post.. and dzedward's? Your php script does not appear to be accessible.
If you click on the link:
Then I believe you should see:
result=An error occured.
In your browser window. But instead you get a 404 page not found.
mmmm, that's crazy, i clicked the link as well and got the same thing but it's there? what's a reason you it wouldn't work?
I don't know. I'm only starting to learn the server-side stuff. And I think you're using PHP with IIS ...right? If so do you have other PHP scripts working... i.e. is it enabled... or is it some sort of security setting e.g. like .htaccess for apache (I have no idea about IIS - if that's what you're using).
But if I put your code on a test page and run in on my local apache/php server it works as it should (i.e. it displays in the browser: result=An error occured). So I think that's the problem that you need to fix.
why are you using POST to send your data and GET to retrieve name?
not sure, like i said i used the source code files and tried to delete the code i didn't need an made it simplier....
can other people get this to work?
i'm pretty sure it's the JpegEncoder class that is with AS 3.0 or the same one floating around the net that everyone uses.
it's a php class written by person(s) unknown to me.
and it's a flash class. but i still don't know who wrote it.
I think the JPEGEncoder class originally came from the other source (I'm not 100% sure but the code is basically identical - there are comments to the effect that a few tweaks have been made). No issue with that though.
What the bytearray implementation does is implement the uploading/saving support .
The implementation at bytearray was done using amfphp (flash remoting with php) with amf3 encoding format.
I presumed you were trying to avoid using amfphp remoting and just transfer the jpeg data in a binary format in your POST method upload. I presume that might work given that you can do binary transfers using as3... although I've never tried it.
But the issue earlier appeared to be that your php script wasn't accessible which is (I believe) an issue unrelated to any of the code and something to do with how your server is set up. (I didn't delve too much into the code yet, because I can't see how it can work at all unless this is addressed first).
Do you have PHP set up on your server? I assumed earlier that you had and that there was some other problem. If you don't have php set up then no php code will run. If you do have it set up then the problem is (I believe) something to do with how things are set up on your server (as long as the create.php file is in the same directory as the html).
Coldfusion has (or used to have when I used it some years back) flash remoting support built in.
But I guess if you can send the jpeg binary data directly via POST you don't need remoting.
If I get time over the weekend I'll see if I can get it working the way you're trying to do it. (My first inclination would be to try to use amfphp and just replicate the bytearray example, but I'm also interested to see if it can work your way). Unless someone beats me to it. ;)
Thanks for all your help. You are clearing up a lot for me. I'm pretty good with Flash but not with other languages.
There actually was a problem with my server, my hosting company was to set-up Coldfusion on a Linux server and enable Flash Remoting, which is what I use for every site I do, basically.
However when we were having the normal "linux / coldfusion" problems they switched me to a windows server and my Flash Remoting worked fine. They did this on 4 sites. I didn't notice because I don't use anything other than Flash, MySQL and Coldfusion. So it turns out I never noticed.
I asked them to switch but then changed my mind. If windows is less buggy with Coldfusion and Flash Remoting I'll just stick with it for the site I'm needing to save the Jpeg on. If the code is just saving the jpeg then the optimal solution would be to just have the coldfusion document save the jpeg.
I would be willing to pay you for helping, I will be using this code in the end for commercial purposes.
If you're curious at all to what it's being used for check out this link:
Go to the design page, click napkins, design up a napkin if you'd like. This site is still in development stage, obviously. I would like to take a jpeg of the designed item and save it, so that it can be email and used for other purposed, i.e. printing guide, later in the process.
Thanks again for all your help, much much appreciated!
The site looks great. And a brilliant match between business opportunity and technology.
I would be willing to pay you for helping, I will be using this code in the end for commercial purposes.
No need. Few reasons:
a) I'm kinda new on the server-side stuff too...if I help out here I get to learn too.
b) I have a copy of Coldfusion (7) somewhere but I'm focusing on php so I'll check it via php (as per your example code) and/or amfphp if that doesn't work.
c) I'm just starting to set up my business and haven't charged anybody anything yet. Ever. lol.
OK... so I tried it this morning (Monday) . It works with PHP - no problems (there will be a problem with PHP 5.2.2 but like I said in an early reply that can be overcome).
With what you have everything works as it should already using php. Remoting is not required. Its great being able to do binary transfers like that. I don't know what the limit is for POST data sizes (or if there is one) but it makes doing something like this really easy. I must start using as3 more!
So if you don't have php but you do have coldfusion or IIS/asp then all you need to do is change the receiving script to the equivalent coldfusion (and the corresponding create.php URLRequest from flash).
You mentioned you use Coldfusion already ... so do you know how to do that?
Great! You rule.
I actually don't know how to do it with Coldfusion but I have an idea. I can use a cfm to create folders and save things. I'm just not sure about the binary transfer and how to do it in Coldfusion.
I still don't have php/linux on my server, where I'm testing it.
I would love to do this in Coldfusion so I can use it on any server. I think a lot of people would love to do this as well. Do you think it can be done with CF?
Yes I can't see why not. All its doing is receiving the raw POST data and saving it as a file. Its quite simple code so I imagine it would be easy to replicate in CF.
If you haven't solved it by tomorrow I'll have a look and see if I can find some inof. But I'd prefer not to have to install CF myself to test it.
Cool, I wish I knew with CF how to save the data. Is it coming in as a jpeg already? If so, what's the variable name? I don't know PHP at all! :) Sorry...
No - Its coming in as binary data via the POST method.
In PHP its seen as $GLOBALS["HTTP_RAW_POST_DATA"]
but basically that is the bytestream that represents that jpg.
All your PHP code is doing is
using the name variable which is passed along with the jpeg data (using the GET method) to save the binary data in a file named 'name'+'.jpg'
All that would be required with CF is to mirror this approach. Perhaps there's a CF forum on here somewhere where someone who knows a lot about CF could port the PHP code....
I just posted it in a Coldfusion forum, hopefully someone will help. I cannot get php/coldfusion hosting anymore. So I need to do this via asp or coldfusion... Thanks for all your help.
If you know of anyone willing to be paid to help find a solution to this, please direct them my way. thanks!
Question, how come I can't get the PHP to work locally? I can't get it to work?
I worked on getting some ASP to work and this is what I got and it won't work either! Grrr....
I have a virtual server set up, using coldfusion. I have a root folder called jpegTestSave. So my link locally is localhost:8500/jpegTestSave/finalTest.html.
The page comes up and the flash movie executes the code to create the binary data. Its there wasn't an error, but no image found? It's tough to trouble shoot because you say it works for you but I can't get it to work locally...
Have you got php installed locally?
If so make sure its not version 5.2.2 the code as it is won't work with that version.
You should be able to verify what version you have with phpinfo. There may be some other settings if its a new install that you need to adjust. For my local machine I use wampserver - its great and easy to set up.
You're using port 8500 for your html. perhaps you need to use it for your other requests if thats the port your local web server is running on.
Then make sure your create.php is in the same directory as your html/swf.
If its all set up like that... then make sure the urls in your code are good.
I used this for my download link:
url_txt.htmlText = "<font color='#990000'><a href='"+myVars.result+"?"
+new Date().getTime()+"' target='_blank'>Snapshot available here</a></font>";
Again if your port is 8500
it would be "localhost:8500/jpegTestSave/"+"+myVars.result+"?"
Okay here's the scoop, I've been working on this for days. I finally got the PHP version to work, locally.
There is a problem with my ASP code, do you know ASP at all? I just need the equivalant in ASP so that no matter what server I'm on it will work. Here is my code:
No I don't know ASP.
I took a quick look here:
I think it might be what you need to get the raw binary POST data.
But.... I can't say for sure.
EDIT: I'm pleased you got the PHP version working. So you know its possible - must be good to see it first hand. It's just a matter of the server-side script for your server scripting language.
Ahhh crap, this sucks. I can't seem to get any help anywhere on this. I don't know any ASP so that link is pretty greek to me.
Know of anywhere I can find somone to help me?
Sorry no I don't.
I'm reluctant to attempt this because like I said I know nothing of ASP (and I don't have access to IIS to test it) ... but here goes:
This is what I would try (at least to start with) from looking at the docs.
I'm least certain about the file saving parts. And if it works (at all) consider it only test code.
Dim jpgPostedData, lngCount, fName, bytesOut
lngCount = Request.TotalBytes
fName = Request.QueryString("name")
If (lngCount > 0 ) then
' save the binary stream
jpgPostedData = Request.BinaryRead(lngCount)
Open App.Path & "\" & fName For Binary Access Write As #1
For bytesOut = 0 To lngCount
Put #1, , (jpgPostedData(bytesOut))
Response.Write "result=" & fName & " was processed as " & lngCount & " bytes."
else Response.Write "result=An error occured."
it also may need a
at before the %> (again... I'm not sure).
I actually just tried it and didn't work.
I really appreciate you still trying. I've been working for days! I still can't get this going.
Still getting this error:
Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: http://localhost/Test/create.asp?name=snapshot.jpg
This is my coldfusion. I can't seem to get any help in the CF Forum...
I'll take a look at the CF docs tomorrow. I'm no expert, but my impression is that reference in Dreamweaver is better than ASP.
And if nothing else I know there are references to doing exactly what you want with remoting in CF because I found them earlier today on a search (the example was exactly the same class - JPEGencoder bitmap upload coded using flex I think) . So there's always that approach - 'tried and trusted' instead of just trying to get the raw POST data (i.e. let remoting do that part for you).
Don't give up just yet.
Well I think I've gotten real close with the Coldfusion writing. First I had to figure out the remoting which I did for reading a string from a CF document. I'm not sure if I'm sending the binary data to CF correctly.
I've zipped up the files for you that I've used for the entire CF version of the save jpeg. They are at
Zip Files Here
Let me know what you think. I found the CF component online from someone else. I'm not sure if it's right.
Thanks again for all your help!
OK, I took a look.
If you successfully got testJpegSave.ImageSave.ROsave to work using the same actionscript for the string/text data test then there are only (in my mind) two things left to check if the binary save is not working.
1. You're sending a byteArray as opposed to a string when you call the remote function with the jpeg data. This requires that CF remoting support is set up for amf3 because the original remoting amf version (I think its called amf1?) doesn't handle some of the new data types in as3 like byteArray. So two things here... check that CF has the remoting update installed... and if there are any settings to switch modes (if that's necessary - I think it is in amfphp) ...i.e. I'm not sure if you need to configure amf3 vs amf1 mode as a CF setting...
Anyhow more info here - check this is available with you CF setup:
2. The other part is the file saving. But as near as I can tell from the CF livedocs (and another example I saw for saving binary data for a jpeg) the way you have
WSsave set up in you CFC looks OK to me.
My guess is its number 1 above.