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.