|
-
How to make a save.php
The swf posts the content to save.php but i dont have a save.php I need to create one but i donno what do put in the save.php as code to get it posted there. Here is the code that requires the save.php to post:
Code:
loc3 = new flash.net.URLRequestHeader("Content-type", "application/x-www-form-urlencoded");
(loc4 = new flash.net.URLRequest(p.rooturl + "/save.php?name=" + arg2 + "&type=" + arg1)).requestHeaders.push(loc3);
loc4.method = flash.net.URLRequestMethod.POST;
loc4.data = arg3;
flash.net.navigateToURL(loc4, "_self");
Close();
How can i make a save.php for this code so it will post it there?
-
That's really a php question, not an as3 question. But from a very basic standpoint, you will need a php interpreter running on the server you are posting to (probably the same one your swf is on) which has a save.php file served from the root html directory. That save.php file will need to look at the "name" and "type" values and anything that's in arg3 (you didn't post that, so we can't know), and generate some response.
You may want to change that code to put name and type in the arg3 object along with other data, because it's a little weird to have some GET encoded variables in a POST request.
-
Well im still a newbie.
Can you tell me the codes i can edit?
I dont have any save.php to grap the file now.
-
No, I'm sorry, I don't speak php.
If I wanted to learn it, I'd start here.
-
Well i just want it to post it on somewhere. It can be save.php or whatever.
I mean i can edit the swf codes also if i need to. I dont care the name or the type either. It can be something simple.
Isnt there anybody can help me about this?
-
-
Sorry but it didint really help. If i knew that much of flash or php i could easly solve the problem. Plus they are talking about a txt file. My swf will extract a picture file to save.php
there are so many actionscripts i cant just start rewriting them. Codes should be accurate now but i can make small changes just to fix this problem.
All i need is a save.php that can grab the picture file which swf exports as you can see in my code above.
-
No, I do not see your code exporting a picture or bytearray. If it is, then that is somewhere in arg3, which is a black box.
I'll assume for the sake of attempting to help that the bytearray representing the picture is stored in arg3 as a property called "content". From what I know of PHP, you should be able to access that data in php by something like (and this is minimally adapted from the page I just linked):
Code:
$pictureBytes = $_POST['content'];
Then you can take those bytes and write them to the filesystem (again, similar to what's shown in the previous link). And at this point, you are definitely asking about php and you would be much better off asking in a php forum.
-
I dont understand something.
There are only 3 files in the folder/ftp
index.html
the swf file
save.php
When i grab the picture from my computer where does it keep/save it for temporaryly?
Then i say save and it exports it to save.php
If i can find an answer to this, i maybe able to grab the editted picture by this
Code:
<?php
echo '<img src="THEPATH/'.$_GET['name'].'" border="0" />';
?>
OR
<?php
echo $_GET['name'].' '.$_GET['type'];
?>
Right now i cant do anything with these get codes because i donno THEPATH/
therefore it gives a broken image link on a blank page.
if it was a php or asp. The file would be saved temporarly somewhere and you would edit it. But flash doesnt seem like its saving it somewhere on ftp. Then how do you see it in swf and edit it?
-
I'm guessing you are not running a webserver, and if you are, are not running one set up to process php.
The point of the save.php file would be to save the submitted picture somewhere in the filesystem. The particular location would depend on how you write save.php.
Also, in the interest of programming safely, be aware that if you put this up on the web you must consider security. The naive way of saving the image file (saving arbitrary files in a web-readable location) would result in a security hole which would lead to server compromise in about 10 seconds.
-
Thx for thr security advice. I will keep that in mind.
I can get the picture and edit it on swf without the save.php in ftp.
So where the picture is standing temporary when i edit it if there are only index.html and swf file?
-
It's in memory at that point. RAM. Or are you asking where it comes from?
-
Well yeah i guess the question what should i put in THEPATH/ ?
Because thas what the save.php will show on the page.
-
You need to make THEPATH the same value as the folder you are saving the images in. It essentially doesn't matter what that value is so long as it's the same in the save and retrieve parts, and that it exists on the filesystem.
-
i fegured out that It actually doesnt matter what i write in THEPATH it goes to http://site.com/deneme/save.php?name...9.jpg&type=jpg
MS_113339.jpg is the name of the file.
And it gives me a picture with broken link there.
-
Here is the entire saving actionscript. I have spent the last 10 hours on this file. I am going crazy now...
Code:
package ui.dialogs
{
import event.*;
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.utils.*;
import image.*;
import image.encoder.*;
import resource.*;
import ui.controls.*;
public class SaveImageDialog extends ui.controls.Dialog
{
public function SaveImageDialog(arg1:Pixlr, arg2:Boolean=false)
{
super(arg1, "rm_save_image", 400, 190, true);
this.removecanvas = arg2;
var loc1:*=new ui.controls.Literal(U.RM("rm_format"), true);
loc1.x = 10;
loc1.y = 30;
loc1.width = 50;
addChild(loc1);
var loc2:*;
(loc2 = new ui.controls.Literal(U.RM("rm_name"), true)).x = 10;
loc2.y = 60;
loc2.width = 50;
addChild(loc2);
var loc3:*;
if ((loc3 = arg1.canvas.document.name).indexOf(".") != -1)
{
loc3 = arg1.canvas.document.name.split(".")[0];
}
this.tbn = new ui.controls.TextInput(220, 100, loc3);
this.tbn.x = 61;
this.tbn.y = 60;
addChild(this.tbn);
this.lttype = new ui.controls.Literal(".jpg");
this.lttype.x = this.tbn.x + this.tbn.width;
this.lttype.y = 62;
addChild(this.lttype);
this.jpgquality = new ui.controls.Slidebar(U.RM("rm_quality"), 0, 100, 100, 80, true);
this.jpgquality.x = 62;
this.jpgquality.y = 90;
addChild(this.jpgquality);
if (arg1.qs.GetValue("target") != null)
{
this.savetotarget = new ui.controls.Radiobutton(U.RM("rm_save_back") + " " + (arg1.qs.GetValue("referrer") == null ? U.RM("rm_referrer") : arg1.qs.GetValue("referrer")));
this.savetotarget.addEventListener(event.ChangeEvent.CHANGE, this.TargetClick);
this.savetotarget.x = 62;
this.savetotarget.y = 130;
addChild(this.savetotarget);
this.savetotarget.Check();
this.savetocomputer = new ui.controls.Radiobutton(U.RM("rm_save_to_computer"));
this.savetocomputer.addEventListener(event.ChangeEvent.CHANGE, this.TargetClick);
this.savetocomputer.x = 62;
this.savetocomputer.y = 150;
addChild(this.savetocomputer);
if (!(arg1.qs.GetValue("locktarget") == null) && arg1.qs.GetValue("locktarget").toLowerCase() == "true")
{
this.savetotarget.visible = false;
this.savetocomputer.visible = true;
}
}
this.format = new ui.controls.Dropdown(220, 220);
this.format.addEventListener(event.SelectEvent.COMMAND, this.FormatChange);
this.format.AddItem("JPEG (Good for most photos)", "jpg", true);
this.format.AddItem("PNG (Transparent, full quality)", "png");
this.format.AddItem("BMP (Large but non-destructive)", "bmp");
this.format.Bind();
this.format.x = 61;
this.format.y = 30;
addChild(this.format);
var loc4:*;
cancel.x = loc4 = 319;
ok.x = loc4;
ok.y = 25;
cancel.y = 54;
return;
}
internal function SaveJpg(arg1:flash.display.BitmapData):void
{
var loc1:*=new image.encoder.JPGEncoder(this.jpgquality.value);
this.Save("jpg", this.tbn.text + ".jpg", loc1.encode(arg1));
return;
}
internal function SavePng(arg1:flash.display.BitmapData):void
{
this.Save("png", this.tbn.text + ".png", image.encoder.PNGEncoder.encode(arg1));
return;
}
internal function StoreError(arg1:flash.events.Event):void
{
trace("error");
Close();
new ui.controls.AlertDialog(p, U.RM("rm_error_occurred"));
return;
}
internal function TargetClick(arg1:event.ChangeEvent):void
{
this.savetotarget.Check(false);
this.savetocomputer.Check(true);
(arg1.target as ui.controls.Radiobutton).Check();
return;
}
internal function StoreComplete(arg1:flash.events.Event):void
{
var loc1:*=undefined;
var loc2:*=null;
trace("store");
if (arg1.target.data != "")
{
loc1 = String(arg1.target.data);
if (loc1.indexOf("ERR") == -1)
{
loc2 = p.qs.GetValue("target");
if (loc2.indexOf("?") != -1)
{
loc2 = loc2 + "&";
}
else
{
loc2 = loc2 + "?";
}
loc2 = loc2 + "image=" + encodeURI(p.rooturl + "/_temp/" + loc1);
loc2 = loc2 + "&type=" + encodeURI(this.format.value);
loc2 = loc2 + "&state=" + encodeURI(p.canvas.document.external ? "fetched" : "new");
loc2 = loc2 + "&title=" + encodeURI(this.tbn.text);
if (p.qs.GetValue("redirect") == null)
{
flash.net.navigateToURL(new flash.net.URLRequest(loc2), "_self");
}
else
{
flash.net.sendToURL(new flash.net.URLRequest(loc2));
flash.net.navigateToURL(new flash.net.URLRequest(p.qs.GetValue("redirect")), "_self");
}
}
else
{
this.StoreError(null);
}
Close();
}
return;
}
public override function OKClick(arg1:flash.events.MouseEvent):void
{
if (this.tbn.text == "")
{
this.tbn.text = U.RM("rm_untitled");
}
var loc1:*=this.format.value;
switch (loc1)
{
case "jpg":
{
p.canvas.UpdateAfterEdit(-1, 16777215);
this.SaveJpg(p.canvas.screenshot);
break;
}
case "png":
{
p.canvas.UpdateAfterEdit();
this.SavePng(p.canvas.screenshot);
break;
}
case "bmp":
{
p.canvas.UpdateAfterEdit();
this.SaveBmp(p.canvas.screenshot);
break;
}
}
if (this.removecanvas)
{
p.RemoveCanvas();
}
return;
}
internal function Save(arg1:String, arg2:String, arg3:flash.utils.ByteArray):void
{
var loc1:*=null;
var loc2:*=null;
var loc3:*=null;
var loc4:*=null;
trace("save");
if ((this.savetotarget == null || this.savetotarget.checked) && !(p.qs.GetValue("target") == null))
{
if (p.qs.GetValue("method") == null || p.qs.GetValue("method").toLowerCase() == "get")
{
(loc1 = new flash.net.URLLoader()).addEventListener(flash.events.Event.COMPLETE, this.StoreComplete);
loc1.addEventListener(flash.events.IOErrorEvent.IO_ERROR, this.StoreError);
loc1.dataFormat = flash.net.URLLoaderDataFormat.BINARY;
loc1.load(image.Misc.GenerateRequest(p.rooturl + "/store.php?type=" + arg1, arg3, arg2, arg1, "store"));
}
else if (!(p.qs.GetValue("credentials") == null) && p.qs.GetValue("credentials").toLowerCase() == "true")
{
loc2 = p.qs.GetValue("target");
if (p.qs.GetValue("redirect") == null)
{
flash.net.navigateToURL(image.Misc.GenerateRequest(loc2, arg3, arg2, arg1, p.canvas.document.external ? "fetched" : "new"), "_self");
}
else
{
flash.net.sendToURL(image.Misc.GenerateRequest(loc2, arg3, arg2, arg1, p.canvas.document.external ? "fetched" : "new"));
flash.net.navigateToURL(new flash.net.URLRequest(p.qs.GetValue("redirect")), "_self");
}
}
else
{
loc2 = (loc2 = (loc2 = p.rooturl + "/forward.php") + "?") + "&url=" + encodeURI(p.qs.GetValue("target"));
if (p.qs.GetValue("redirect") == null)
{
flash.net.navigateToURL(image.Misc.GenerateRequest(loc2, arg3, arg2, arg1, p.canvas.document.external ? "fetched" : "new"), "_self");
}
else
{
flash.net.sendToURL(image.Misc.GenerateRequest(loc2, arg3, arg2, arg1, p.canvas.document.external ? "fetched" : "new"));
flash.net.navigateToURL(new flash.net.URLRequest(p.qs.GetValue("redirect")), "_self");
}
}
}
else
{
loc3 = new flash.net.URLRequestHeader("Content-type", "application/x-www-form-urlencoded");
(loc4 = new flash.net.URLRequest(p.rooturl + "/save.php?name=" + arg2 + "&type=" + arg1)).requestHeaders.push(loc3);
loc4.method = flash.net.URLRequestMethod.POST;
loc4.data = arg3;
flash.net.navigateToURL(loc4, "_self");
Close();
}
return;
}
internal function FormatChange(arg1:event.SelectEvent):void
{
this.jpgquality.visible = false;
var loc1:*=arg1.val as String;
switch (loc1)
{
case "jpg":
{
this.jpgquality.visible = true;
this.lttype.text = ".jpg";
break;
}
case "png":
{
this.lttype.text = ".png";
break;
}
case "bmp":
{
this.lttype.text = ".bmp";
break;
}
}
return;
}
internal function SaveBmp(arg1:flash.display.BitmapData):void
{
var loc1:*=new image.encoder.BMPEncoder();
this.Save("bmp", this.tbn.text + ".bmp", loc1.encode(arg1));
return;
}
var tbn:ui.controls.TextInput;
var lttype:ui.controls.Literal;
internal var savetotarget:ui.controls.Radiobutton;
internal var savetocomputer:ui.controls.Radiobutton;
var removecanvas:Boolean;
internal var uploadURL:flash.net.URLRequest;
internal var format:ui.controls.Dropdown;
internal var ld:ui.controls.LoadDialog;
internal var file:flash.net.FileReference;
var jpgquality:ui.controls.Slidebar;
}
}
I want it to either save it on save.php or save it on computer.
I have already changed the savetocomputer options to "true" but they didint make any change. It doesnt show the "save to computer" option.
Cmon people! Please somebody help me!
-
That's far too confusing to really do much with. You could try to debug it and step through each line, or use trace statements to figure out which code path is being taken.
Is it even getting to the line where it submits to save.php?
-
If you look for 2-3 minutes its actually pretty good organized.
I color coded them for you.
Save.php stuff
Save to Computer stuff
Code:
package ui.dialogs
{
import event.*;
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.utils.*;
import image.*;
import image.encoder.*;
import resource.*;
import ui.controls.*;
public class SaveImageDialog extends ui.controls.Dialog
{
public function SaveImageDialog(arg1:Pixlr, arg2:Boolean=false)
{
super(arg1, "rm_save_image", 400, 190, true);
this.removecanvas = arg2;
var loc1:*=new ui.controls.Literal(U.RM("rm_format"), true);
loc1.x = 10;
loc1.y = 30;
loc1.width = 50;
addChild(loc1);
var loc2:*;
(loc2 = new ui.controls.Literal(U.RM("rm_name"), true)).x = 10;
loc2.y = 60;
loc2.width = 50;
addChild(loc2);
var loc3:*;
if ((loc3 = arg1.canvas.document.name).indexOf(".") != -1)
{
loc3 = arg1.canvas.document.name.split(".")[0];
}
this.tbn = new ui.controls.TextInput(220, 100, loc3);
this.tbn.x = 61;
this.tbn.y = 60;
addChild(this.tbn);
this.lttype = new ui.controls.Literal(".jpg");
this.lttype.x = this.tbn.x + this.tbn.width;
this.lttype.y = 62;
addChild(this.lttype);
this.jpgquality = new ui.controls.Slidebar(U.RM("rm_quality"), 0, 100, 100, 80, true);
this.jpgquality.x = 62;
this.jpgquality.y = 90;
addChild(this.jpgquality);
if (arg1.qs.GetValue("target") != null)
{
this.savetotarget = new ui.controls.Radiobutton(U.RM("rm_save_back") + " " + (arg1.qs.GetValue("referrer") == null ? U.RM("rm_referrer") : arg1.qs.GetValue("referrer")));
this.savetotarget.addEventListener(event.ChangeEvent.CHANGE, this.TargetClick);
this.savetotarget.x = 62;
this.savetotarget.y = 130;
addChild(this.savetotarget);
this.savetotarget.Check();
this.savetocomputer = new ui.controls.Radiobutton(U.RM("rm_save_to_computer"));
this.savetocomputer.addEventListener(event.ChangeEvent.CHANGE, this.TargetClick);
this.savetocomputer.x = 62;
this.savetocomputer.y = 150;
addChild(this.savetocomputer);
if (!(arg1.qs.GetValue("locktarget") == null) && arg1.qs.GetValue("locktarget").toLowerCase() == "true")
{
this.savetotarget.visible = false;
this.savetocomputer.visible = true;
}
}
this.format = new ui.controls.Dropdown(220, 220);
this.format.addEventListener(event.SelectEvent.COMMAND, this.FormatChange);
this.format.AddItem("JPEG (Good for most photos)", "jpg", true);
this.format.AddItem("PNG (Transparent, full quality)", "png");
this.format.AddItem("BMP (Large but non-destructive)", "bmp");
this.format.Bind();
this.format.x = 61;
this.format.y = 30;
addChild(this.format);
var loc4:*;
cancel.x = loc4 = 319;
ok.x = loc4;
ok.y = 25;
cancel.y = 54;
return;
}
internal function SaveJpg(arg1:flash.display.BitmapData):void
{
var loc1:*=new image.encoder.JPGEncoder(this.jpgquality.value);
this.Save("jpg", this.tbn.text + ".jpg", loc1.encode(arg1));
return;
}
internal function SavePng(arg1:flash.display.BitmapData):void
{
this.Save("png", this.tbn.text + ".png", image.encoder.PNGEncoder.encode(arg1));
return;
}
internal function StoreError(arg1:flash.events.Event):void
{
trace("error");
Close();
new ui.controls.AlertDialog(p, U.RM("rm_error_occurred"));
return;
}
internal function TargetClick(arg1:event.ChangeEvent):void
{
this.savetotarget.Check(false);
this.savetocomputer.Check(true);
(arg1.target as ui.controls.Radiobutton).Check();
return;
}
internal function StoreComplete(arg1:flash.events.Event):void
{
var loc1:*=undefined;
var loc2:*=null;
trace("store");
if (arg1.target.data != "")
{
loc1 = String(arg1.target.data);
if (loc1.indexOf("ERR") == -1)
{
loc2 = p.qs.GetValue("target");
if (loc2.indexOf("?") != -1)
{
loc2 = loc2 + "&";
}
else
{
loc2 = loc2 + "?";
}
loc2 = loc2 + "image=" + encodeURI(p.rooturl + "/_temp/" + loc1);
loc2 = loc2 + "&type=" + encodeURI(this.format.value);
loc2 = loc2 + "&state=" + encodeURI(p.canvas.document.external ? "fetched" : "new");
loc2 = loc2 + "&title=" + encodeURI(this.tbn.text);
if (p.qs.GetValue("redirect") == null)
{
flash.net.navigateToURL(new flash.net.URLRequest(loc2), "_self");
}
else
{
flash.net.sendToURL(new flash.net.URLRequest(loc2));
flash.net.navigateToURL(new flash.net.URLRequest(p.qs.GetValue("redirect")), "_self");
}
}
else
{
this.StoreError(null);
}
Close();
}
return;
}
public override function OKClick(arg1:flash.events.MouseEvent):void
{
if (this.tbn.text == "")
{
this.tbn.text = U.RM("rm_untitled");
}
var loc1:*=this.format.value;
switch (loc1)
{
case "jpg":
{
p.canvas.UpdateAfterEdit(-1, 16777215);
this.SaveJpg(p.canvas.screenshot);
break;
}
case "png":
{
p.canvas.UpdateAfterEdit();
this.SavePng(p.canvas.screenshot);
break;
}
case "bmp":
{
p.canvas.UpdateAfterEdit();
this.SaveBmp(p.canvas.screenshot);
break;
}
}
if (this.removecanvas)
{
p.RemoveCanvas();
}
return;
}
internal function Save(arg1:String, arg2:String, arg3:flash.utils.ByteArray):void
{
var loc1:*=null;
var loc2:*=null;
var loc3:*=null;
var loc4:*=null;
trace("save");
if ((this.savetotarget == null || this.savetotarget.checked) && !(p.qs.GetValue("target") == null))
{
if (p.qs.GetValue("method") == null || p.qs.GetValue("method").toLowerCase() == "get")
{
(loc1 = new flash.net.URLLoader()).addEventListener(flash.events.Event.COMPLETE, this.StoreComplete);
loc1.addEventListener(flash.events.IOErrorEvent.IO_ERROR, this.StoreError);
loc1.dataFormat = flash.net.URLLoaderDataFormat.BINARY;
loc1.load(image.Misc.GenerateRequest(p.rooturl + "/store.php?type=" + arg1, arg3, arg2, arg1, "store"));
}
else if (!(p.qs.GetValue("credentials") == null) && p.qs.GetValue("credentials").toLowerCase() == "true")
{
loc2 = p.qs.GetValue("target");
if (p.qs.GetValue("redirect") == null)
{
flash.net.navigateToURL(image.Misc.GenerateRequest(loc2, arg3, arg2, arg1, p.canvas.document.external ? "fetched" : "new"), "_self");
}
else
{
flash.net.sendToURL(image.Misc.GenerateRequest(loc2, arg3, arg2, arg1, p.canvas.document.external ? "fetched" : "new"));
flash.net.navigateToURL(new flash.net.URLRequest(p.qs.GetValue("redirect")), "_self");
}
}
else
{
loc2 = (loc2 = (loc2 = p.rooturl + "/forward.php") + "?") + "&url=" + encodeURI(p.qs.GetValue("target"));
if (p.qs.GetValue("redirect") == null)
{
flash.net.navigateToURL(image.Misc.GenerateRequest(loc2, arg3, arg2, arg1, p.canvas.document.external ? "fetched" : "new"), "_self");
}
else
{
flash.net.sendToURL(image.Misc.GenerateRequest(loc2, arg3, arg2, arg1, p.canvas.document.external ? "fetched" : "new"));
flash.net.navigateToURL(new flash.net.URLRequest(p.qs.GetValue("redirect")), "_self");
}
}
}
else
{
loc3 = new flash.net.URLRequestHeader("Content-type", "application/x-www-form-urlencoded");
(loc4 = new flash.net.URLRequest(p.rooturl + "/save.php?name=" + arg2 + "&type=" + arg1)).requestHeaders.push(loc3);
loc4.method = flash.net.URLRequestMethod.POST;
loc4.data = arg3;
flash.net.navigateToURL(loc4, "_self");
Close();
}
return;
}
internal function FormatChange(arg1:event.SelectEvent):void
{
this.jpgquality.visible = false;
var loc1:*=arg1.val as String;
switch (loc1)
{
case "jpg":
{
this.jpgquality.visible = true;
this.lttype.text = ".jpg";
break;
}
case "png":
{
this.lttype.text = ".png";
break;
}
case "bmp":
{
this.lttype.text = ".bmp";
break;
}
}
return;
}
internal function SaveBmp(arg1:flash.display.BitmapData):void
{
var loc1:*=new image.encoder.BMPEncoder();
this.Save("bmp", this.tbn.text + ".bmp", loc1.encode(arg1));
return;
}
var tbn:ui.controls.TextInput;
var lttype:ui.controls.Literal;
internal var savetotarget:ui.controls.Radiobutton;
internal var savetocomputer:ui.controls.Radiobutton;
var removecanvas:Boolean;
internal var uploadURL:flash.net.URLRequest;
internal var format:ui.controls.Dropdown;
internal var ld:ui.controls.LoadDialog;
internal var file:flash.net.FileReference;
var jpgquality:ui.controls.Slidebar;
}
}
Last edited by Website_PLB; 12-10-2010 at 10:28 PM.
-
Senior Member
May be you are looking for this. There is a php file also.
http://flashscript.biz/flashas3/biz/...ByteArray.html
- The right of the People to create Flash movies shall not be infringed. -
-
Here is what the php file shows as a result:
"myResult=Could not place the file"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|