# Simple image upload problem

**URL:** https://forum.kirupa.com/t/simple-image-upload-problem/264871
**Category:** Uncategorized
**Created:** [July 1, 2008, 2:48pm UTC](https://forum.kirupa.com/t/simple-image-upload-problem/264871 "2008-07-01T14:48:54Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![energy](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@energy](https://forum.kirupa.com/u/energy)
#### Post date: [July 1, 2008, 2:48pm UTC](https://forum.kirupa.com/t/simple-image-upload-problem/264871/1 "2008-07-01T14:48:54Z")

</div>

Hi Everyone,  
I opened a thread on this issue in Flash forum also but i think this might be a PHP issue so please have a look at it.  
I am trying to upload an image on my server using Flash and PHP. The following code works fine on 1 server but doesn’t work on other 2 servers where i have to implement it. Please check it and see where am i going wrong.  
FLA CODE:

* * *

\*\*listener.onSelect = function(selectedFile:FileReference):Void {

// Flash is attempting to upload the image.  
statusArea.text += "Wait…trying to upload " + selectedFile.name + "  
";

selectedFile.upload(“upload.php”);

## };\*\*

## PHP CODE:

## \*\*\<?php $target = “./”; $target = $target . $\_FILES[‘Filedata’][‘name’]; move\_uploaded\_file($\_FILES[‘Filedata’][‘tmp\_name’], $target); chmod("./".$\_FILES[‘Filedata’][‘name’], 777); ?\> \*\*

The other 2 servers shows that it is uploading but doesn’t upload. Not sure if flash is executing PHP file on those.  
I am really struggling to make it work on other servers. I just cldn’t understand the logic that why does it just work on one server and not others. Any kind of help will be highly appreciated.

Thanks for reading.

---

<div class="post-metadata">

### Author: ![Charleh](https://avatars.discourse-cdn.com/v4/letter/c/a9a28c/32.png) [@Charleh](https://forum.kirupa.com/u/Charleh)
#### Post date: [July 1, 2008, 3:13pm UTC](https://forum.kirupa.com/t/simple-image-upload-problem/264871/2 "2008-07-01T15:13:20Z")

</div>

Is PHP installed and configured correctly on the other 2 servers?

---

<div class="post-metadata">

### Author: ![energy](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@energy](https://forum.kirupa.com/u/energy)
#### Post date: [July 1, 2008, 3:20pm UTC](https://forum.kirupa.com/t/simple-image-upload-problem/264871/3 "2008-07-01T15:20:11Z")

</div>

Yes PHP is installed , i can upload through html and php using the same code but not when i use Flash. Is there anything else i have to do in installation to make flash work with PHP.

---

<div class="post-metadata">

### Author: ![energy](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@energy](https://forum.kirupa.com/u/energy)
#### Post date: [July 1, 2008, 3:38pm UTC](https://forum.kirupa.com/t/simple-image-upload-problem/264871/4 "2008-07-01T15:38:02Z")

</div>

And one more thing. I have  
listener.onComplete also in my flash code which shows it has “uploaded”.

And one of the two non-working servers even executes that. But the other doesn’t come in listener.onComplete.

---

<div class="post-metadata">

### Author: ![Charleh](https://avatars.discourse-cdn.com/v4/letter/c/a9a28c/32.png) [@Charleh](https://forum.kirupa.com/u/Charleh)
#### Post date: [July 1, 2008, 4:28pm UTC](https://forum.kirupa.com/t/simple-image-upload-problem/264871/5 "2008-07-01T16:28:12Z")

</div>

Sounds like a directory permissions thing - I’d check all the permissions on all servers to see if there are any differences

---

<div class="post-metadata">

### Author: ![energy](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@energy](https://forum.kirupa.com/u/energy)
#### Post date: [July 1, 2008, 4:58pm UTC](https://forum.kirupa.com/t/simple-image-upload-problem/264871/6 "2008-07-01T16:58:20Z")

</div>

HI,  
Thanks for all your help mate. I tried changing the directory permissions to everything from 775, 777, 644… but it still doesn’t load. ☹

I don’t use PHp much but is there any chance that the server needs some other syntax to execute it?

## I used PHP with html with permissions 644 and it uploads. Here is the PHP code i used with HTML:

\*\*\<?php  
$target = “./”;  
$target = $target . basename( $\_FILES[‘uploaded’][‘name’]) ;

## $change = basename( $\_FILES[‘uploaded’][‘name’]); move\_uploaded\_file($\_FILES[‘uploaded’][‘tmp\_name’], $target) ?\>\*\*

Actually there is only one server out of the 2 non working hosts where i need it, but there it doesn’t even return to listener.onComplete in Flash. Not sure what all it is doing in the background.

---

<div class="post-metadata">

### Author: ![energy](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@energy](https://forum.kirupa.com/u/energy)
#### Post date: [July 1, 2008, 6:41pm UTC](https://forum.kirupa.com/t/simple-image-upload-problem/264871/7 "2008-07-01T18:41:49Z")

</div>

Ok i think there might be some issue in the security features of my host as i searched. Thanks for your help.  
I will put it here if that is the case because everything else seems all right.
