/    Sign up×
Community /Pin to ProfileBookmark

php move_uploaded_file does not write to local directory

I am trying to have a PHP form that takes in a maximum of three images from the user and puts them in a specified directory in my htdocs directory (using Apache).

PHP Documentation: [url]http://us.php.net/manual/en/features…ad.post-method[/url]

It had a script to something very similar to what I am trying to do. However, this is my code:

[code=php]
<form action=”fileupload.php” method=”post” enctype=”multipart/form-data”>
<p>Pictures:<br>
<input type=”file” name=”pictures[]” /><br>
<input type=”file” name=”pictures[]” /><br>
<input type=”file” name=”pictures[]” /><br>
<input type=”submit” name=”submit” value=”Send” />
</p>
</form>

<?php

if ($_POST[“submit”]) {
echo “SUBMITTED<br>”;
foreach ($_FILES[“pictures”][“error”] as $key => $error) {
echo “go throught the files<br>”;
if ($error == UPLOAD_ERR_OK) {
echo “ERROR: ” . $error . “<br>”;
$tmp_name = $_FILES[“pictures”][“tmp_name”][$key];
echo “tmp_name: ” . $tmp_name . “<br>”;
$name = $_FILES[“pictures”][“name”][$key];
echo “name: ” . $name . “<br>”;
move_uploaded_file($tmp_name, “data/$name”);
}
}
}
?>
[/code]

and this is my php.ini file where I changed the upload_path accordingly:

[code]

;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
upload_tmp_dir = “C:Program FilesApache Software FoundationApache2.2htdocsminiimagesgallery”

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M
[/code]

When i write out $tmp_name is comes out as:
tmp_name: C:DOCUME~1CRAIGR~1LOCALS~1Tempphpuploadphp7 4.tmp

What is going wrong here?

Cheers,
Picco
?

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @crmpicco spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.13,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...