Jump to content


Photo

Form post problam. *SOLVED*


  • Please log in to reply
7 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 May 2006 - 02:14 AM

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.

<? 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>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 13 May 2006 - 02:36 AM

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]

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 May 2006 - 03:15 AM

Still no joy please help.



test_result.php
<?
echo "'".$_FILES['userfile']['size']."'";
echo "'".$_FILES['userfile']['type']."'";
?>

form.php


<? 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>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 13 May 2006 - 07:40 AM

I don't see anything wrong, but try echoing $_FILES['userfile']['error']...

#5 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 13 May 2006 - 02:06 PM

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>';

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 May 2006 - 07:24 PM

[!--quoteo(post=373510:date=May 13 2006, 02:06 PM:name=toplay)--][div class=\'quotetop\']QUOTE(toplay @ May 13 2006, 02:06 PM) View Post[/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
Array
(
    [userfile] => Array
        (
            [name] => computer3.gif
            [type] => 
            [tmp_name] => 
            [error] => 2
            [size] => 0
        )

)

Array
(
    [userfile] => Array
        (
            [name] => makingsqlconnection.txt
            [type] => text/plain
            [tmp_name] => C:\WINDOWS\TEMP\php2D1.tmp
            [error] => 0
            [size] => 4620
        )

)

But a text file has all the data in the array
Anythink else like any other file exstention nothink in the array please help.



php.ini

;;;;;;;;;;;;;;;;
; File Uploads;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
file_uploads = On

; Maximum allowed size for uploaded files.
upload_max_filesize = 24000000M


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 13 May 2006 - 07:59 PM

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.



#8 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 May 2006 - 08:05 PM

[!--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
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>';


The error i had

Array
(
    [userfile] => Array
        (
            [name] => computer3.gif
            [type] => 
            [tmp_name] => 
            [error] => 2
            [size] => 0
        )

)


my problam in the end

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


error codes as advised from toplay

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. 

my solved 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>



Thanks to toplay i got it all done correctly and it all made so much sence cheers mate!!!!!!!!!!!!
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users