calmchess Posted January 17, 2009 Share Posted January 17, 2009 I have a form field that uploads a picture but when i say in my script if !$_POST['pic'] in order to send an error message if the field is empty then it always comes back as being empty is there something else i need to use for the file type? or how do I ask a field if its empty or not? Link to comment https://forums.phpfreaks.com/topic/141228-picture-form-field-doesnt-understand-_post/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 17, 2009 Share Posted January 17, 2009 You probably need to read the upload section in the php manual or read an upload tutorial to get the basic information needed to do this because the uploaded file is not available in a $_POST variable. Link to comment https://forums.phpfreaks.com/topic/141228-picture-form-field-doesnt-understand-_post/#findComment-739184 Share on other sites More sharing options...
calmchess Posted January 17, 2009 Author Share Posted January 17, 2009 I looked at the manual but all i could find is $_FILES but it always returns ARRAY.....don't know how to say if !$_FILES then give error message. could you help with a code example. Link to comment https://forums.phpfreaks.com/topic/141228-picture-form-field-doesnt-understand-_post/#findComment-739194 Share on other sites More sharing options...
RichardRotterdam Posted January 17, 2009 Share Posted January 17, 2009 the $_FILES var is exactly what you need. it is indeed an array which you can use for validation. Link to comment https://forums.phpfreaks.com/topic/141228-picture-form-field-doesnt-understand-_post/#findComment-739203 Share on other sites More sharing options...
calmchess Posted January 17, 2009 Author Share Posted January 17, 2009 well i managed to echo the array using print_r $_FILES['uploaded']; but i cannot figure out how to access each slot in the array so i can run an if statment on it...anybody have any more input? Link to comment https://forums.phpfreaks.com/topic/141228-picture-form-field-doesnt-understand-_post/#findComment-739217 Share on other sites More sharing options...
dawsba Posted January 17, 2009 Share Posted January 17, 2009 I'd suggest starting at looking into how arrays work not difficult once you get the basics. http://www.howtoforge.com/php_arraysgood site for details Link to comment https://forums.phpfreaks.com/topic/141228-picture-form-field-doesnt-understand-_post/#findComment-739220 Share on other sites More sharing options...
calmchess Posted January 17, 2009 Author Share Posted January 17, 2009 I trie $_FILES[0]; but that returns nothing Link to comment https://forums.phpfreaks.com/topic/141228-picture-form-field-doesnt-understand-_post/#findComment-739226 Share on other sites More sharing options...
calmchess Posted January 17, 2009 Author Share Posted January 17, 2009 nevermind i figured it out ....this is a multidemsional array to me $_FILES['uploaded']['name']; Link to comment https://forums.phpfreaks.com/topic/141228-picture-form-field-doesnt-understand-_post/#findComment-739235 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.