Jump to content

Form post problam. *SOLVED*


redarrow

Recommended Posts

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_name

For 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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

[!--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 array
Anythink 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
Share on other sites

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
Share on other sites

[!--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_SIZE
Value: 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_OK
Value: 0; There is no error, the file uploaded with success.

UPLOAD_ERR_INI_SIZE
Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.

UPLOAD_ERR_FORM_SIZE
Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.

UPLOAD_ERR_PARTIAL
Value: 3; The uploaded file was only partially uploaded.

UPLOAD_ERR_NO_FILE
Value: 4; No file was uploaded.

UPLOAD_ERR_NO_TMP_DIR
Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.

UPLOAD_ERR_CANT_WRITE
Value: 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
Share on other sites

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.