# Uploading files through flash 8

**URL:** https://forum.kirupa.com/t/uploading-files-through-flash-8/180584
**Category:** flash
**Created:** [March 1, 2006, 6:06pm UTC](https://forum.kirupa.com/t/uploading-files-through-flash-8/180584 "2006-03-01T18:06:51Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Macro\_design](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Macro\_design](https://forum.kirupa.com/u/Macro_design)
#### Post date: [March 1, 2006, 6:06pm UTC](https://forum.kirupa.com/t/uploading-files-through-flash-8/180584/1 "2006-03-01T18:06:51Z")

</div>

Hi

I know that this is a wellcovered topic, but every time I try making an upload I get a 401 or 403 error. So I figure it should be something with the permission, however, I’ve set all of the files and folder to ‘777’.

Anyone who has experienced the same problems?

Or if you have experience with this working, and know a tutorial which helped you, I would just love a link :sure:

Thanks for the help

BTW. my host is [flashlevel.net](http://flashlevel.net), so it should be compatible with PHP, right?

---

<div class="post-metadata">

### Author: ![dominus](https://avatars.discourse-cdn.com/v4/letter/d/b5ac83/32.png) [@dominus](https://forum.kirupa.com/u/dominus)
#### Post date: [April 5, 2006, 12:48am UTC](https://forum.kirupa.com/t/uploading-files-through-flash-8/180584/2 "2006-04-05T00:48:15Z")

</div>

> [@pete\_zahut](#):
>
> OK, I did it!  
> You should load them to the server with php 🙂
> 
> I have this piece of php :
> 
> ```php
> <?PHP
> $target_path = "uploads/";
> $target_path = $target_path . basename( $_FILES['Filedata']['name']);
> 
> if(move_uploaded_file($_FILES['Filedata']['tmp_name'], $target_path))
> {
> echo "The file ". basename( $_FILES['Filedata']['name']). " has been uploaded";
> }
> else
> {
> echo "There was an error uploading the file, please try again!";
> }
> ?>
> 
> ```
> 
> But is this secure? Are there ways to secure it?  
> Like the image width & height , size, …

i’ve used this code and it works perfect on my computer… i have php 5.0.4 installed… but when i put this on the web, it’s no longer working… ☹ what can cause this? i’m almost sure it’s something about security access

---

<div class="post-metadata">

### Author: ![pete\_zahut](https://avatars.discourse-cdn.com/v4/letter/p/91b2a8/32.png) [@pete\_zahut](https://forum.kirupa.com/u/pete_zahut)
#### Post date: [April 5, 2006, 6:37am UTC](https://forum.kirupa.com/t/uploading-files-through-flash-8/180584/3 "2006-04-05T06:37:35Z")

</div>

Make sure your directories or files you want to edit or write to have the security settings to 666 or 777.  
Or for a directory it should look like this: drwxrwxrwx for a file -rwxrwxrwx.

In your ftp programme you can alter these permissions, right click \> Properties

---

<div class="post-metadata">

### Author: ![dominus](https://avatars.discourse-cdn.com/v4/letter/d/b5ac83/32.png) [@dominus](https://forum.kirupa.com/u/dominus)
#### Post date: [April 5, 2006, 10:05am UTC](https://forum.kirupa.com/t/uploading-files-through-flash-8/180584/4 "2006-04-05T10:05:06Z")

</div>

it’s set to 777… i’ve also added a input file in the php and the upload is working… the problem is that when i am uploading a file from the flash it’s not… also the browser seems to stop responding ☹

---

<div class="post-metadata">

### Author: ![dominus](https://avatars.discourse-cdn.com/v4/letter/d/b5ac83/32.png) [@dominus](https://forum.kirupa.com/u/dominus)
#### Post date: [April 5, 2006, 3:45pm UTC](https://forum.kirupa.com/t/uploading-files-through-flash-8/180584/5 "2006-04-05T15:45:40Z")

</div>

does anyone have at least an ideea of what the problem could be? the php is from the same domain, the folder permissions are set correctly. I really need to get this fixed. Any help would be greatly appreciated. At least to point me to the right direction in fixing this problem. Thank you very much

---

<div class="post-metadata">

### Author: ![pete\_zahut](https://avatars.discourse-cdn.com/v4/letter/p/91b2a8/32.png) [@pete\_zahut](https://forum.kirupa.com/u/pete_zahut)
#### Post date: [April 5, 2006, 5:37pm UTC](https://forum.kirupa.com/t/uploading-files-through-flash-8/180584/6 "2006-04-05T17:37:35Z")

</div>

Can’t see the problem :puzzled:

Can you post your code?

---

<div class="post-metadata">

### Author: ![dominus](https://avatars.discourse-cdn.com/v4/letter/d/b5ac83/32.png) [@dominus](https://forum.kirupa.com/u/dominus)
#### Post date: [April 6, 2006, 11:30am UTC](https://forum.kirupa.com/t/uploading-files-through-flash-8/180584/7 "2006-04-06T11:30:45Z")

</div>

> [@pete\_zahut](#):
>
> Can’t see the problem :puzzled:
> 
> Can you post your code?

PHP Code

```php
<?PHP
    $target_path = "images/";
    $target_path = $target_path . basename( $_FILES['Filedata']['name']);
    if(move_uploaded_file($_FILES['Filedata']['tmp_name'], $target_path))
    {
         echo "The file ". basename( $_FILES['Filedata']['name']). " has been uploaded";
    }
    else
    {
         echo "There was an error uploading the file, please try again!";
    }
?> 

```

The test.php is in the same directory with the test\_upload.swf/html The permissions on the images folder are 777. The images folder is in the same location with the swf, php and html.

The flash code:

```auto

import flash.net.FileReference;
var listener:Object = new Object();
listener.onSelect = function(selectedFile:FileReference):Void {
	statusArea.text += "Attempting to upload "+selectedFile.name+"
";
	selectedFile.upload("test.php");
};
listener.onOpen = function(selectedFile:FileReference):Void {
    fileName = "images/"+selectedFile.name;
	statusArea.text += "images/"+selectedFile.name+"
";
};
listener.onComplete = function(selectedFile:FileReference):Void {
	statusArea.text += "Downloading "+selectedFile.name+" to player
";
	imageName = selectedFile.name;
	downloadImage();
};
var imageFile:FileReference = new FileReference();
imageFile.addListener(listener);
function imageDownloaded(event:Object):Void {
	if (event.total == -1) {
		statusArea.text += "ERROR
";
	}
}
uploadBtn.onRelease = function(){
	imageFile.browse([{description:"Image Files", extension:"*.jpg;*.gif;*.png"}]);
}
function downloadImage(event:Object):Void {
	_root.createEmptyMovieClip("holder",_root.getNextHighestDepth());
 	holder.loadMovie(fileName);
}

```

And here is the .fla file.

Test location is here: www.keyconcept.ro/work/onlinedesigner/test\_upload.html

The code works perfectly on my home computer.  
Also, when i open the page in IE, and i try to close it. It seems to get stucked on something

---

<div class="post-metadata">

### Author: ![dominus](https://avatars.discourse-cdn.com/v4/letter/d/b5ac83/32.png) [@dominus](https://forum.kirupa.com/u/dominus)
#### Post date: [April 6, 2006, 4:57pm UTC](https://forum.kirupa.com/t/uploading-files-through-flash-8/180584/8 "2006-04-06T16:57:42Z")

</div>

does someone know where the problem could be? could this be from the php file? or it is from the flash file? the php uploader works fine when a input file form is added to the php(the one with browse)

---

<div class="post-metadata">

### Author: ![dominus](https://avatars.discourse-cdn.com/v4/letter/d/b5ac83/32.png) [@dominus](https://forum.kirupa.com/u/dominus)
#### Post date: [April 7, 2006, 12:16pm UTC](https://forum.kirupa.com/t/uploading-files-through-flash-8/180584/9 "2006-04-07T12:16:45Z")

</div>

let’s ask this question different… has someone done file uploading on a server? if so, could you please share your php code and the fla files? thank you

---

<div class="post-metadata">

### Author: ![dominus](https://avatars.discourse-cdn.com/v4/letter/d/b5ac83/32.png) [@dominus](https://forum.kirupa.com/u/dominus)
#### Post date: [April 7, 2006, 8:09pm UTC](https://forum.kirupa.com/t/uploading-files-through-flash-8/180584/10 "2006-04-07T20:09:25Z")

</div>

problem solved(i guess)

i tested the file uploader on another server. On the initial server i kept recieving this http error : 406
