redarrow Posted May 13, 2006 Share Posted May 13, 2006 I have a problam the hidden post varables are not there example when you post a form deppending on input name you get the following hidden posts.in my case i use userfile:$userfile_size$userfile_type$userfile_nameFor some reason i can not get the $userfile_size of the hidden varable post or $userfile_type varable post.I tested the hidden post varables and the result is blank for $userfile_type and a 0 for userfile_size.but i got the file i n the database by the userfile_name.Also if i use the $_post statement all varables goes blank.Has anyone got any idears please thank you.My code example.[code]<? session_start();?><html><head><body><h1>please upload a picture!</h1><br><form enctype="multipart/form-data" action="members_upload_picture_result.php" method="post"><input type="hidden" name="max_file_size" value="20000"><br>Please choose a picture<br><input type="file" name="userfile"><br><input type="submit" value="send"><br></form></html></body>[/code] Link to comment https://forums.phpfreaks.com/topic/9576-form-post-problam-solved/ Share on other sites More sharing options...
toplay Posted May 13, 2006 Share Posted May 13, 2006 The data will be in the $_FILES array. See:[a href=\"http://us2.php.net/manual/en/features.file-upload.php\" target=\"_blank\"]http://us2.php.net/manual/en/features.file-upload.php[/a]Also, access non upload file variables using $_POST and not $_post. See:[a href=\"http://us2.php.net/manual/en/reserved.variables.php#reserved.variables.post\" target=\"_blank\"]http://us2.php.net/manual/en/reserved.vari....variables.post[/a] Link to comment https://forums.phpfreaks.com/topic/9576-form-post-problam-solved/#findComment-35365 Share on other sites More sharing options...
redarrow Posted May 13, 2006 Author Share Posted May 13, 2006 Still no joy please help.test_result.php[code]<?echo "'".$_FILES['userfile']['size']."'";echo "'".$_FILES['userfile']['type']."'";?>[/code]form.php[code]<? session_start();?><html><head><body><h1>please upload a picture!</h1><br><form enctype="multipart/form-data" action="test_result.php" method="post"><input type="hidden" name="max_file_size" value="20000"><br>Please choose a picture<br><input name="userfile" type="file"><br><input type="submit" value="send"><br></form></html></body>[/code] Link to comment https://forums.phpfreaks.com/topic/9576-form-post-problam-solved/#findComment-35379 Share on other sites More sharing options...
448191 Posted May 13, 2006 Share Posted May 13, 2006 I don't see anything wrong, but try echoing [u]$_FILES['userfile']['error'][/u]... Link to comment https://forums.phpfreaks.com/topic/9576-form-post-problam-solved/#findComment-35426 Share on other sites More sharing options...
toplay Posted May 13, 2006 Share Posted May 13, 2006 It's "MAX_FILE_SIZE" in all uppercase.Also, you might want to check your php.ini settings especially to see if file_uploads is on (see links provided earlier).While testing/debugging this, make sure you have error_reporting(E_ALL); at the top of your script so you can see all of PHP's errors/warnings/notices. Also, I assume you have display_errors on in the php.ini file. Otherwise, set it using ini_set('display_errors', '1'); at the top of your script too.In test_result.php display everything in $_FILES like:echo '<pre>', print_r($_FILES, TRUE), '</pre>'; Link to comment https://forums.phpfreaks.com/topic/9576-form-post-problam-solved/#findComment-35481 Share on other sites More sharing options...
redarrow Posted May 13, 2006 Author Share Posted May 13, 2006 [!--quoteo(post=373510:date=May 13 2006, 02:06 PM:name=toplay)--][div class=\'quotetop\']QUOTE(toplay @ May 13 2006, 02:06 PM) [snapback]373510[/snapback][/div][div class=\'quotemain\'][!--quotec--]It's "MAX_FILE_SIZE" in all uppercase.Also, you might want to check your php.ini settings especially to see if file_uploads is on (see links provided earlier).While testing/debugging this, make sure you have error_reporting(E_ALL); at the top of your script so you can see all of PHP's errors/warnings/notices. Also, I assume you have display_errors on in the php.ini file. Otherwise, set it using ini_set('display_errors', '1'); at the top of your script too.In test_result.php display everything in $_FILES like:echo '<pre>', print_r($_FILES, TRUE), '</pre>';[/quote]list of errow[code]Array( [userfile] => Array ( [name] => computer3.gif [type] => [tmp_name] => [error] => 2 [size] => 0 ))[/code][code]Array( [userfile] => Array ( [name] => makingsqlconnection.txt [type] => text/plain [tmp_name] => C:\WINDOWS\TEMP\php2D1.tmp [error] => 0 [size] => 4620 ))[/code][b]But a text file has all the data in the arrayAnythink else like any other file exstention nothink in the array please help.[/b]php.ini[code];;;;;;;;;;;;;;;;; File Uploads;;;;;;;;;;;;;;;;;; Whether to allow HTTP file uploads.file_uploads = On; Maximum allowed size for uploaded files.upload_max_filesize = 24000000M[/code] Link to comment https://forums.phpfreaks.com/topic/9576-form-post-problam-solved/#findComment-35538 Share on other sites More sharing options...
toplay Posted May 13, 2006 Share Posted May 13, 2006 Read what error 2 is and fix it:[a href=\"http://us2.php.net/manual/en/features.file-upload.errors.php\" target=\"_blank\"]http://us2.php.net/manual/en/features.file-upload.errors.php[/a]After file is uploaded with no errors, you have to copy it from the $_FILES['userfile']['tmp_name'] to where you want to permanently store it. Link to comment https://forums.phpfreaks.com/topic/9576-form-post-problam-solved/#findComment-35542 Share on other sites More sharing options...
redarrow Posted May 13, 2006 Author Share Posted May 13, 2006 [!--sizeo:5--][span style=\"font-size:18pt;line-height:100%\"][!--/sizeo--]SOLVED[!--sizec--][/span][!--/sizec--][!--sizeo:5--][span style=\"font-size:18pt;line-height:100%\"][!--/sizeo--]errow checking for post array in a form[!--sizec--][/span][!--/sizec--] thank you toplay your grate!How i found my errow [code]As your see from the below MAX_FILE_SIZE is set high in my case i get good result on all exstsntion uploads while testing.In the php.ini the uploads must be set on as above.MAX_FILE_SIZE must be upercase as pointed out via toplay.Thanks every one cheers.It's "MAX_FILE_SIZE" in all uppercase.Also, you might want to check your php.ini settings especially to see if file_uploads is on (see links provided earlier).While testing/debugging this, make sure you have error_reporting(E_ALL); at the top of your script so you can see all of PHP's errors/warnings/notices. Also, I assume you have display_errors on in the php.ini file. Otherwise, set it using ini_set('display_errors', '1'); at the top of your script too.In test_result.php display everything in $_FILES like:echo '<pre>', print_r($_FILES, TRUE), '</pre>';[/code]The error i had[code]Array( [userfile] => Array ( [name] => computer3.gif [type] => [tmp_name] => [error] => 2 [size] => 0 ))[/code]my problam in the end[code]UPLOAD_ERR_FORM_SIZEValue: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form. [/code]error codes as advised from toplay[code]UPLOAD_ERR_OKValue: 0; There is no error, the file uploaded with success. UPLOAD_ERR_INI_SIZEValue: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini. UPLOAD_ERR_FORM_SIZEValue: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form. UPLOAD_ERR_PARTIALValue: 3; The uploaded file was only partially uploaded. UPLOAD_ERR_NO_FILEValue: 4; No file was uploaded. UPLOAD_ERR_NO_TMP_DIRValue: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3. UPLOAD_ERR_CANT_WRITEValue: 7; Failed to write file to disk. Introduced in PHP 5.1.0. Note: These became PHP constants in PHP 4.3.0. [/code]my solved code[code]<html><head><body><h1>please upload a file!</h1><br><form enctype="multipart/form-data" action="upload.php" method="post"><input type="hidden" name="max_file_size" value="200000"><br>please choose a file<br><input type="file" name="userfile"><br><input type="submit" value="send"><br></form></html></body>[/code]Thanks to toplay i got it all done correctly and it all made so much sence cheers mate!!!!!!!!!!!! Link to comment https://forums.phpfreaks.com/topic/9576-form-post-problam-solved/#findComment-35546 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.