Skip to main content
July 16, 2007
Question

flash as3.0 screen shot with php

  • July 16, 2007
  • 37 replies
  • 4382 views
hello, i'm so close to actually getting this to work and i'm breaking down and asking for some help. here is my actionscript and php codes, why doesn't this work?

the link for a preview and the error:
Link here

This topic has been closed for replies.

37 replies

Inspiring
July 25, 2007
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))
Next
Close #1
Response.Write "result=" & fName & " was processed as " & lngCount & " bytes."
End If

else Response.Write "result=An error occured."

%>

it also may need a

Response.End

at before the %> (again... I'm not sure).
July 24, 2007
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?
Inspiring
July 23, 2007
No I don't know ASP.

I took a quick look here:
http://msdn2.microsoft.com/en-us/library/ms525710.aspx

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.
Inspiring
July 23, 2007
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+"?"
+new Date().getTime()+"'

I guess

July 23, 2007
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:
July 23, 2007
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...
July 23, 2007
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!

Carey
Inspiring
July 23, 2007
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....



July 23, 2007
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...
Inspiring
July 23, 2007
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.

July 23, 2007
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?