/    Sign up×
Community /Pin to ProfileBookmark

Upload file problem

I am having a problem using a upload file script.

[code=php]

function upload ($set){
$uploaddir = ‘../../_images/Sets/$set/’;
$uploadfile = $uploaddir . basename($_FILES[‘file’][‘name’]);
echo ‘<pre>’;
if (move_uploaded_file($_FILES[‘upfile’][‘tmp_name’], $uploadfile)) {
echo “File is valid, and was successfully uploaded.n”;
} else {
echo “Possible file upload attack!n”;
}
echo ‘Here is some more debugging info:’;
print_r($_FILES);
print “</pre>”;
}

[/code]

the error message reads

[CODE]

Possible file upload attack!
Here is some more debugging info:Array
(
[file] => Array
(
[name] => CTechLogo.gif
[type] => image/gif
[tmp_name] => /tmp/phpveJvur
[B] [error] => 0[/B]
[size] => 2930
)

)

[/CODE]

But i dont know what that meens

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@scragarDec 30.2008 — ['upfiles'] is not a valid index, you will want to check that first.

I would also check your file upload dir, make sure the directory exists([url=http://php.net/is_dir]is_dir()[/url]), that could save you a few errors.

And in future, when attempting to debug code, try turning error reporting to it's highest level, it would have told you about this:
[code=php]
error_reporting(E_ALL);
[/code]
×

Success!

Help @moiseszaragoza 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.18,
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,
)...