zvijerka Posted April 26, 2010 Share Posted April 26, 2010 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... Quote Link to comment https://forums.phpfreaks.com/topic/199797-empty-_files-on-image-upload/ Share on other sites More sharing options...
Pikachu2000 Posted April 26, 2010 Share Posted April 26, 2010 cant really be of much help without seeing the form and code that processes it . . . Quote Link to comment https://forums.phpfreaks.com/topic/199797-empty-_files-on-image-upload/#findComment-1048704 Share on other sites More sharing options...
zvijerka Posted April 26, 2010 Author Share Posted April 26, 2010 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); Quote Link to comment https://forums.phpfreaks.com/topic/199797-empty-_files-on-image-upload/#findComment-1048711 Share on other sites More sharing options...
de.monkeyz Posted April 26, 2010 Share Posted April 26, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/199797-empty-_files-on-image-upload/#findComment-1048713 Share on other sites More sharing options...
zvijerka Posted April 26, 2010 Author Share Posted April 26, 2010 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?? Quote Link to comment https://forums.phpfreaks.com/topic/199797-empty-_files-on-image-upload/#findComment-1048718 Share on other sites More sharing options...
de.monkeyz Posted April 26, 2010 Share Posted April 26, 2010 Can you post the PHP code for this? It's hard to tell Quote Link to comment https://forums.phpfreaks.com/topic/199797-empty-_files-on-image-upload/#findComment-1048720 Share on other sites More sharing options...
zvijerka Posted April 26, 2010 Author Share Posted April 26, 2010 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... Quote Link to comment https://forums.phpfreaks.com/topic/199797-empty-_files-on-image-upload/#findComment-1048738 Share on other sites More sharing options...
newbtophp Posted April 26, 2010 Share Posted April 26, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/199797-empty-_files-on-image-upload/#findComment-1048743 Share on other sites More sharing options...
PFMaBiSmAd Posted April 26, 2010 Share Posted April 26, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/199797-empty-_files-on-image-upload/#findComment-1048745 Share on other sites More sharing options...
zvijerka Posted April 26, 2010 Author Share Posted April 26, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/199797-empty-_files-on-image-upload/#findComment-1048748 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.