0

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?

1
  • the first parameter should be $_FILES['imagem']['tmp_name'] and try using ./images/. Commented Dec 17, 2015 at 14:44

2 Answers 2

0

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.