-
user uploading image
does anyone know how to code it so the user can upload their own images?
do u have to use html coding for it?
im using flash 8,
this is a query relating to a uni project.
thank u for ur advice
Christine Roberts
Student Graphic Designer
-
Senior Member
PHP + a database and probably MYSQL as well
-
thanks for your reply ill try and play around and see if it i can make it work.
-
Truimagz.com
here is what you do........
first find out what type of hosting you have.
If you have the ability to get frontpage extensions installed then thats the easiet way. If so let me know I'll tell you how to do it.
If you can not have those extension installed then you need to create a php upload page. Let me know if this is how you must do it.
Once you have established these two things, you then create a new folder on your hosting account, call it what ever you want. Then set its permissions to allow anonamous uploads or 777.
Then create a mysql database to hold the users info when they create an account on your site.
Then when a user uploads an image via the methods previously stated, also have the user give the picture a name. Then send the pictures actual name and type as well as what the user named it to the myql.
Then inside flash were all user pics will be shown have flash ask what user do you want to views pictures of.
Then have flash send that user info to php-mysql and retrieve all the users pic extensions, save those as variable (ie, pic1 , pic2) then send those variable back to flash.
Inside the movie clip that will show the picture just say this.loadMovie (foldername/and the variable).
Thats it
-
CostomJunky
I wrote this class for gif picture uploading using kirupa's tutorial you can specify other piture types below if you want...
Code:
import flash.net.FileReference;
class logo_upload_c {
var reference:FileReference;
var referenceListener:Object;
var scriptLocation:String;
var uploadButton_mc:MovieClip;
var chooseButton_mc:MovieClip;
var display_txt;
var target:MovieClip;
function logo_upload_c() {
reference = new FileReference();
referenceListener = {};
scriptLocation = _root.root_dir+"uploader.php";
reference.addListener(referenceListener);
referenceListener.onSelect = activateUploadButton;
referenceListener.onProgress = updateProgress;
referenceListener.onComplete = restart;
referenceListener.onHTTPError = handleError;
referenceListener.onIOError = handleError;
referenceListener.onSecurityError = handleError;
}
function setUploadMC(mc) {
uploadButton_mc = mc;
uploadButton_mc._visible = false;
}
function setBrowseMC(mc) {
chooseButton_mc = mc;
}
function setDisplayText(ref) {
display_txt = ref;
}
function setMainMC(mc) {
target = mc;
}
function activateUploadButton(file:FileReference) {
if (file.size<=2500) {
_root.logoUpload.display_txt.text = _root.logoUpload.reference.name;
_root.logoUpload.uploadButton_mc._visible = true;
} else {
}
}
// allow gif's only
function choose() {
reference.browse([{description:'All Files (*.*)', extension:'*.gif*'}]);
}
function handleError(errorName:String, detail:Object):Void {
restart();
if (arguments.length === 2) {
if (typeof detail === 'number') {
_root.logoUpload.display_txt.text = 'HTTP Error #'+detail;
} else {
_root.logoUpload.display_txt.text = 'Security Error: '+detail;
}
} else {
_root.logoUpload.display_txt.text = 'IO Error';
}
}
function restart() {
removeMovieClip(progressBar);
_root.logoUpload.display_txt.text = '';
_root.logoUpload.uploadButton_mc._visible = false;
_root.logoUpload.chooseButton_mc._visible = true;
// update the image count after uploading...
}
function updateProgress(fileReference:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
_root.logoUpload.display_txt.text = fileReference.name+' - '+Math.ceil((bytesLoaded/bytesTotal)*100)+'%';
progressBar._width = Math.ceil(Stage.width*(bytesLoaded/bytesTotal));
}
function uploadCurrent() {
chooseButton_mc._visible = false;
progressBar = makeProgressBar(0, progressBarY);
reference.upload(scriptLocation);
}
}
inside the button mc with reference name: browse_button
Code:
on(release){
logoUpload.choose();
}
inside the button mc with reference name: upload_button
Code:
on (release) {
logoUpload.uploadCurrent();
}
Actions Frame in _root.
Code:
var root_dir = "";
var logoUpload:logo_upload_c = new logo_upload_c();
logoUpload.setUploadMC(upload_button);
logoUpload.setBrowseMC(browse_button);
logoUpload.setDisplayText(display_txt);
logoUpload.setMainMC(this);
Lastly create folder named graphics, and a file named uploader.php then insert this bit of code:
Code:
<?php
if ($_FILES['Filedata']['name']) {
move_uploaded_file($_FILES['Filedata']['tmp_name'], 'graphics/' . basename($_FILES['Filedata']['name']));
}
?>
-
Senior Member
Does that allow for animated gifs?
-
CostomJunky
Originally Posted by mbenney
Does that allow for animated gifs?
Yes, you can upload animated gifs, I just tested it. The only problem is that my image loader class doesn't support animated gifs.
By the way, one thing I didn't mention is that I set a filesize limit - in the class - you can take it out if you want.
see this line:
Code:
if (file.size<=2500) {
_root.logoUpload.display_txt.text = _root.logoUpload.reference.name;
_root.logoUpload.uploadButton_mc._visible = true;
} else {
}
or you can add on to the else and send an error message letting the user know that the file size is too big.
-
Thank you Xploder and everfornever for your advice.
-
Senior Member
And they play the animation? Or just the first frame?
-
first frame only,
you can load the animated GIF or PNG (yes PNG can be animated as well- see newest Firefox alpha release) with AS3 as bytedata and then encrypt it. Esspecially the open PNG format should be easy to find resources on the net regarding it´s structure.
PNG animation support is however veeery rare in applications- almost none in commercial ones.
-
Senior Member
Once you have established these two things, you then create a new folder on your hosting account, call it what ever you want. Then set its permissions to allow anonamous uploads or 777.
Not to be a dick, but I want to correct something here. NEVER set a web-accessible folder with permissions of 777. That's just asking for someone to upload a shell script and really hose the system/account. In practice, most companies would go balistic if they knew someone had set a web-accessible directory with public read + write access at all.
In general, if the folder is owned by the process that will handle writing the uploads (PHP in this case) you should be able to get away with 644 (rw-r--r--). That will allow PHP to write the file as well as read it for sending it to the browser and allow everyone else on the system to see it but not doing anything to it. Most importantly, this will prevent PHP from being used to execute it.
This all depends on the server configuration as well though, you might need 664 depending on how things are set up. One thing is certain; be damn careful when you allow people to upload things to your server. It's always best to set the permissions too low and then increase them as needing to get things working.
-
This is greta info.
Where can I find all the 777 and 664-like codes to see what kind of settings are available?
-
And if I may. What if I just want someone to write, but not see or access?
Thanks.
-
Senior Member
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
|