I just did a search for a method to upload files to a directory and found an old post with links that are not longer valid.
Anyone have a tutorial to create an uploader or know where I can find some source for it?
Printable View
I just did a search for a method to upload files to a directory and found an old post with links that are not longer valid.
Anyone have a tutorial to create an uploader or know where I can find some source for it?
Do a search for the fileReference class. Any of the Macromedia/Adobe examples you find can have the coding ported to Koolmoves. These act just like the one Wilbert added to the Exchange (download a large file and that is the class in action...the upload side of things works similar). Almost all Adobe examples of the class show an example script. Same with any available on the net for Flash itself.
Speaking of Adobe Flash...
I notice flash uses layers and frames.
What would those compare to in KM?
Meaning, I have a layer that has ONLY actionscript in it.
Then there is a layer with the text fields and stuff like that.
Then there is a layer with a movie clip (I think)
Would those be frames or should I think of fla layers as a single frame in KM as their position in the frame? (As in Front / Back)
Here is some AS I found for an uploader.
What version AS is it?...How does one tell anyway.
Code:import flash.net.FileReference;
var allTypes:Array = new Array();
var imageTypes:Object = new Object();
imageTypes.description = "Images (*.jpg, *.jpeg, *.gif, *.png)";
imageTypes.extension = "*.jpg; *.jpeg; *.gif; *.png";
allTypes.push(imageTypes);
var listener:Object = new Object();
listener.onSelect = function(file:FileReference):Void {
log.addItem("File selected for upload");
filename_txt.text = file.name;
size.text = file.size;
type.text = file.type;
name.text = file.name;
datem.text = file.modificationDate;
datec.text = file.creationDate;
}
listener.onCancel = function(file:FileReference):Void {
log.addItem("File upload/download cancelled by user");
}
listener.onOpen = function(file:FileReference):Void {
log.addItem("onOpen: " + file.name);
}
listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
progress.mode = "manual";
progress.setProgress(bytesLoaded, bytesTotal);
log.addItem("bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
}
listener.onComplete = function(file:FileReference):Void {
progress._visible = false;
log.addItem("File is uploaded");
}
listener.onHTTPError = function(file:FileReference, httpError:Number):Void {
log.addItem("HTTP Error :" + httpError);
// Write code here to do corrective actions
}
listener.onIOError = function(file:FileReference):Void {
log.addItem("An IO Error occured");
}
listener.onSecurityError = function(file:FileReference, errorString:String):Void {
log.addItem("SecurityError: " + file.name + " ErrorString: " + errorString, "Error");
}
var fileRef:FileReference = new FileReference();
fileRef.addListener(listener);
browse.onRelease = function()
{
upload.enabled = true;
fileRef.browse([{description: "Image files", extension: "*.jpg;*.gif;*.png", macType: "JPEG;jp2_;GIFF"}]);
}
upload.onRelease = function()
{
this.enabled = false;
/*** Change the URL here to point to the location where your upload.php resides **/
fileRef.upload("http://www.yoursite.com/upload.php");
}
layers dont realy matter kool moves puts them in to layers for you layers realy do nothing except make it eaiser to find something you want to change.
That is AS2. AS3 is class based and any commands/functions would be methods of the class.
EX:
package components
{
import mx.controls.ComboBox;
import flash.display.Sprite;
public class CountryComboBox extends ComboBox
{
public function CountryComboBox()
{
var c:ComboBox = new ComboBox();
c.name = "dropdownlist";
c.text = "dropdownlistText";
addChild(c);
var background:Sprite = new Sprite();
background.name = "Background";
background.graphics.beginFill(0xFF0000);
background.graphics.drawRect(0, 0, 100, 100);
background.graphics.endFill();
c.addChild(background);
dataProvider = [ "United States", "United Kingdom" ];
}
}
}
So, this definitely won't work.
Most of it seems the same? Except for the fileReference stuff. I'm guessing this is where the problem lies.
Quote:
Originally Posted by dniezby
Not as AS2. It needs to be ported down to AS1.
Well, if anyone wants to play around with the coding, here is the *.fun file
I took this from an actual *.fla file and duplicated all of the information in KM.
(Yes, I have flash 8 but it's not as easy to use as KM and I just got it so, I don't know it and I'm extremely fond of KM's usability)
If you need to see the *.fla I can upload that too.
Code ported to AS1Code:var allTypes = new Array();
var imageTypes = new Object();
imageTypes.description = "Images (*.jpg, *.jpeg, *.gif, *.png)";
imageTypes.extension = "*.jpg; *.jpeg; *.gif; *.png";
allTypes.push(imageTypes);
var listener = new Object();
listener.onSelect = function(file) {
log.addItem("File selected for upload");
filename_txt.text = file.name;
size.text = file.size;
type.text = file.type;
name.text = file.name;
datem.text = file.modificationDate;
datec.text = file.creationDate;
}
listener.onCancel = function(file) {
log.addItem("File upload/download cancelled by user");
}
listener.onOpen = function(file) {
log.addItem("onOpen: " + file.name);
}
listener.onProgress = function(file, bytesLoaded, bytesTotal) {
progress.mode = "manual";
progress.setProgress(bytesLoaded, bytesTotal);
log.addItem("bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
}
listener.onComplete = function(file) {
progress._visible = false;
log.addItem("File is uploaded");
}
listener.onHTTPError = function(file, httpError) {
log.addItem("HTTP Error :" + httpError);
// Write code here to do corrective actions
}
listener.onIOError = function(file) {
log.addItem("An IO Error occured");
}
listener.onSecurityError = function(file, errorString) {
log.addItem("SecurityError: " + file.name + " ErrorString: " + errorString, "Error");
}
var fileRef = new flash.net.FileReference();
fileRef.addListener(listener);
browse.onRelease = function()
{
upload.enabled = true;
fileRef.browse([{description: "Image files", extension: "*.jpg;*.gif;*.png", macType: "JPEG;jp2_;GIFF"}]);
}
upload.onRelease = function()
{
this.enabled = false;
/*** Change the URL here to point to the location where your upload.php resides **/
fileRef.upload("http://www.yoursite.com/upload.php");
}
I'm getting nothing from this script.
Maybe I'm putting the script in the wrong place? I put it in the frame.
If you are using the KM component buttons, you need to use onClick instead of onRelease.
You also have to make sure your export setting is set to flash 8.
Making those changes now.
Great catch on the Export as Flash 8...I guess it switched to 6 on it's own because of the minimum version required.
BTW, while on the subject. Which is generally better to use. Component Buttons or Symbol buttons....Is there a recommended situation when one is required over the other?
Anyone know what this error might be?
SecurityError:thefiles's name ErrorString: securitySandboxError
HOLY CRAP.
I figured out how to fix the errors that I was getting.
I will send this to Koolexchange when I package it all up and make some notes.
All I say is, flash definitely made some security changes.
Ok, I've uploaded the package to Koolexchange for approval.
I've also posted it for download at a support forum on one of my sites here
http://www.nssclan.org/forum/viewtopic.php?p=128#128
You can test it out (No files will actually be uploaded) here
Are you not going to include the needed upload.php? Please add it and resubmit it. The readme.txt is appreciated by the way.Quote:
Originally Posted by dniezby
Quote:
Are you not going to include the needed upload.php?
The question is who wrote the php and are there any requirements as far as use and distribution? This is one of the things I'm having issues with in this platform and some of the mods know I take decompiling and code jacking seriously. If we are going to port we had better honor the wishes of the creators of the code we are porting or we are violating restrictions (if any, but who the hecks .fla was this?). If this is an adobe example you had sure better credit them :)
At the very least whoever wrote it should be credited for aiding Koolmovers by giving them an honorable mention even if the code is CCL, GNU or any other. This is an important issue. The only code a submitter gets to disregard this rule IMO is for code they literally write from scratch. No?
Should the new submitter take credit and write credit to themselves?..of course.....for porting it or advancing it...but the originator should get his/her due too. Look close at the current cases being brought down on license infrigement. If you think Koolexchange can't get sued and that our disclaimer protects us...think again. Granted in some cases we have no idea where code comes from and use the honor system but this one we know was ported...so what are the details of that port? There was another recently as well we should have scrutinized IMO for the same reasons.
I'm not crapping on dniezby here also. I want him to get credit for the effort. I also practice what I preach, I've been waiting two days for an email confirmation to release a desktop app PARTIALLY based on opensource that was even stated IN the opensource I could re-distribute but out of respect I felt it was worth contacting the originator and asking permission to advance the code AND distribute as a desktop program (which just tonight he confirmed I could and thanked me for the heads up). I credit myself and them.
If it were just a matter of porting anything I see and submitting it, our Exchange would be stuffed and I wouldn't spend months building things :)
We can't just do that man.
The actionscript is from macromedia livedocs example.. The PHP I don't know where that comes from. The example on Livedocs is CGI and ASP......
I agree we must always be careful to clearly credit ported code..... The only thing I see in Dave's submission that gives me pause in this regard is the copywrite and Creative Commons notices.
He can copyright his advancements or port date but he should also add the originators copyright (or add the date he used it).
He can't CCL code that originated without it, he can only honor an original CCL but not re-CCL it. Most CC licenses carry through all ports since they have to remain as written tied to the originator.
If on the other hand it states "for personal use only" (Don't know...haven't seen it)...it can't even be legally ported and submited ANYWHERE (this is where guys start to twist minor bits and end run the license in most cases). It can only be ported for just that...personal use.
Unless he has the matching PHP...we can't guess. The only one I know who is running a working one is the Exchange (unless only downloads are using the fileReference class). Wilbert most likely has one lying around and I have five or six from last year when I ran my own files before the Exchange existed. Say the word and I'll dig them out (I cd archive everything I do for exactly this reason...so no person can ever approach the Exchange as far as my code....I can prove what I built since I save every single build as it builds....even for the simplest of things) I'll be happy to hand it off to dniezby or whoever to get a working version in the Exchange we can safely distribute.
The php is usually needed on the upload side of things because it's a failsafe that checks file type, size and other things using the PHP command set as well as decides where the file is stored and checks to make sure the file doesn't already exist. Download fileReference examples on the other hand usually just need a hard coded path to the file to pump (or sent in if tied to a dynamic routine like I suspect Wilberts is).
Ok, so you don't go tearing your hair out. As the owner of a multimedia company I deal with copyright and intellectual property rights on a daily basis. I have a full legal department that checks this stuff all the time. I assure you there is nothing here that violates any ones' rights.
The idea of this came from necessity and inspired by this site. I created the design and all of the GUI for it. I got the AS2 code in the public domain. Most of the code is standard syntax according to Flash LiveDocs. I made changes that didn't do what I wanted. Fortunately, the AS2 was ported down to AS1 by w.brants for me. (Who does get credit) I wrote the whole php routine (all 13 lines) based on research from php.net
The Creative Commons License is just so someone doesn't take the design, intended for use as a learning tool and begin selling it (plus the graphic just looked cool there). That is the legal term of "Commercial Use" . Using it to make money is commercial use.
Here it is right from the US Copyright Laws "any manner that is primarily intended for or directed toward commercial advantage or private monetary compensation."
That being said, I have fixed the myUploader.zip file and added the upload.php file that I forgot. Anyone is free to use the code and modify it to your hearts desire. Make it look different and do something a little different and it's all yours.
Enjoy.
Upload your uploader
I have been trying to use his uploader but I am getting a error 405. Any clues?
That would indicate a server error, Try again
Sorry about the delay. I'm not getting notified when messages are for me or not.
As for your issue. Yes, I remember getting this before.
You have to do something on the server side. Let me see if I can find out what I did with the solution.
OOOk I remember this issue. You need to install a cross domain policy.
Open a text editor and put this in it.
Then save the file as crossdomain.xmlCode:<cross-domain-policy>
<allow-access-from domain="www.yoursite.com" />
<allow-access-from domain="yoursite.com" />
<allow_access_from domain="http://www.yoursite.com/subdirectory/" />
<allow_access_from domain="yoursite.com/subdirectory/" />
<allow_access_from domain="yoursite.com" />
</cross-domain-policy>
Upload it to the main folder of your server.
That should do it.
For some reason that didn't work either.
Post the contents of your crossdomain.xml here.
- <cross-domain-policy>
<allow-access-from domain="www.nakefrog.net" />
<allow-access-from domain="nakedfrog.net" />
<allow_access_from domain="http://www.nakedfrog.net/uploads/" />
<allow_access_from domain="http://www.nakedfrog.net/uploads/uploads/" />
<allow_access_from domain="nakedfrog.net/uploads/uploads/" />
<allow_access_from domain="nakedfrog.net/uploads/" />
<allow_access_from domain="nakedfrog.net" />
</cross-domain-policy>
LOL, check your syntax...
allow_ not allow-
One more note, check your spelling too.
Ok, this is what I got now. still doesn't work
<cross-domain-policy>
<allow_access_from domain="www.nakedfrog.net" />
<allow_access_from domain="nakedfrog.net" />
<allow_access_from domain="http://www.nakedfrog.net/uploads/" />
<allow_access_from domain="http://www.nakedfrog.net/uploads/uploads/" />
<allow_access_from domain="nakedfrog.net/uploads/uploads/" />
<allow_access_from domain="nakedfrog.net/uploads/" />
<allow_access_from domain="nakedfrog.net" />
</cross-domain-policy>
I'll have to download it and check it out again. I can't look up the issue cause I lost all my files due to a crash.
Thank you
Ok, I've done a little research on the issue.
I googled FileReference 405 Error and it looks like you need to check your paths.
Check the paths in the fun file and check the paths in the PHP file. Make sure they're all pointing to the correct URLs.
Check the actionscript in the fun file and make sure they're all correct as well. I know I put in some comments to help with the installation.
Let me know if you've found any problems there...There is a bit to check.
OH also, what is the type of file you're trying to upload. If it's not in the array, you're going to have to add it to the authorized files.
I need to upload a video file as well as pictures.
That may be your problem.
You have to open the fun file and change the file types.
It is giving me errors. It says line 43 expecting something...
Also the fun file won't open with koolmoves. I had to import the swf file.