Jump to content

Recommended Posts

hi people!

 

i need some help.

 

i am building some kind of catalogue and i have page where clients can upload their company logo. when i submit that form $_FILES array is empty. i have correct enctype and all php.ini settings in place. $_POST submits through same form but $_FILES is empty.

 

i have a few hidden inputs as well in that form which i use to control application.

 

can someone help me, i am going mad on this...

Link to comment
https://forums.phpfreaks.com/topic/199797-empty-_files-on-image-upload/
Share on other sites

it's a simple form:

	
        echo "<form method=\"post\" enctype=\"multipart/form-data\" action=\"index.php\" />\n";
echo "<input type=\"hidden\" name=\"s\" value=\"galerija\">\n";
echo "<input type=\"file\" name=\"image\">\n";
echo "<input type=\"submit\" name=\"upload\" value=\"Spremi\">\n";
echo "</form>\n";

 

"s" hidden input tells to index.php to include galerija.php in which i just wrote print_r($_FILES);

What size file are you trying to upload?

 

Also, it's unnecessary to echo out that form, you may as well just type it as normal html outside the <?php ?> tags.

 

files are smaller than 100kb

 

i know it's unnecessary but it'm my way of doing these simple forms, i like it all to be inside <?php ?> tags (i'm freak, i know), but could that be the reason of problem. i don't think so...

 

maybe it's because i'm including this galerija.php inside index.php??? when i try same form outside it works (i just tried it), but why it isn't working this way??

include 'header.php';

if(isset($_GET['s'])) {
$s = $_GET['s'];
} else if(isset($_POST['s'])) {
$s = $_POST['s'];
} else {
$s = 'naslovnica';
}

include $s.'.php';

include 'footer.php';

 

that's index.php simplified. other stuff (css and html) i deleted to be clear...

include 'header.php';

if(isset($_GET['s'])) {
$s = $_GET['s'];
} else if(isset($_POST['s'])) {
$s = $_POST['s'];
} else {
$s = 'naslovnica';
}

include $s.'.php';

include 'footer.php';

 

that's index.php simplified. other stuff (css and html) i deleted to be clear...

 

Lookinto remote file inclusion, your code is vulnerabile

If we assume that your actual code is not clearing the $_FILES array due to a logic error in your code (which you did not post), the only things that would cause the files array to be empty but the post array to work would be -

 

1) Nested form tags, where the first <form tag does not have the correct enctype.

2) Uploads are not enabled on your server.

include 'header.php';

if(isset($_GET['s'])) {
$s = $_GET['s'];
} else if(isset($_POST['s'])) {
$s = $_POST['s'];
} else {
$s = 'naslovnica';
}

include $s.'.php';

include 'footer.php';

 

that's index.php simplified. other stuff (css and html) i deleted to be clear...

 

Lookinto remote file inclusion, your code is vulnerabile

 

i know, as i said this is simplified...

 

If we assume that your actual code is not clearing the $_FILES array due to a logic error in your code (which you did not post), the only things that would cause the files array to be empty but the post array to work would be -

 

1) Nested form tags, where the first <form tag does not have the correct enctype.

2) Uploads are not enabled on your server.

 

ok, i'll check everything once more, i know that i'm doing something wrong, but i just can't find out what

 

thanks!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.