0
votes

I'm trying to upload a file but i doesnt work:

Usefull Info: Running IIS Express (with PHP 5.3) - Windows 7 Professional 32 Bits

Code:

move_uploaded_file($_FILES["imagem"]["name"], "/images/" . $_FILES["imagem"]["name"]) or die ("Error:".print_r($_FILES));

It Prints: Array ( [imagem] => Array ( [name] => Chrysanthemum.jpg [type] => image/jpeg [tmp_name] => C:\Windows\Temp\php3D85.tmp [error] => 0 [size] => 879394 ) )

I'm sure the path is correct and i also did chmod() to set permissions but still, doesn't upload.
Any sugestions?

2
the first parameter should be $_FILES['imagem']['tmp_name'] and try using ./images/.Anish Silwal

2 Answers

0
votes

Your destination path should start with a proper path to the images directory (dirname(__FILE__) can help). As it stands, "/images/" . $_FILES["imagem"]["name"] means it'll try to write to C:/images/ (assuming the script is in the C: drive) which probably doesn't exist.

0
votes

Since its is inside of an array you need to execute the move uploaded file function inside of foreach loop.

foreach($_FILES['imagem'] as $f){
move_uploaded_file($f['tmp_name'], "/images/" . $f["name"]);
}

You might wanna try using my class: http://code.google.com/p/daves-upload-class/source/browse/upload_class.php