enctype

This is a discussion on "enctype" within the PHP Forum section. This forum, and the thread "enctype are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Mar 11th, 2006, 14:16
New Member
Join Date: Feb 2006
Age: 23
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
enctype

Hi,

When I use enctype="multipart/form-data" to transfer data to another page. The other pages doesnt reference the form values when I try to apply it to a variable when I submit it i.e $userfile=$_POST['userfile'];

I get an index error for usefile value. Any help would be great.
Reply With Quote

  #2 (permalink)  
Old Mar 16th, 2006, 21:45
Junior Member
Join Date: Mar 2006
Location: Bradford, West Yorkshire, UK
Age: 25
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to jdickinson Send a message via AIM to jdickinson Send a message via MSN to jdickinson Send a message via Yahoo to jdickinson Send a message via Skype™ to jdickinson
Thumbs up Re: enctype

The $_FILES array is where PHP stores all the information about uploaded files, rather than $_POST.

Try changing to: $userfile=$_FILES['userfile']['tmp_name'];

If you want to see what's going on with the from post try adding:
PHP: Select all

<pre>
<?
print_r
($_POST);
print_r($_FILES);
?>
</pre>
This will show you what the post and files variables contain.
Reply With Quote
  #3 (permalink)  
Old Mar 20th, 2006, 14:42
New Member
Join Date: Feb 2006
Age: 23
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Re: enctype

Hi, thanks for the help but it still comes up with the same error with reference to undefined index.

Any other advice would be great

Thanks
Reply With Quote
  #4 (permalink)  
Old Mar 20th, 2006, 15:16
New Member
Join Date: Feb 2006
Age: 23
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Re: enctype

This is the code I have - it references values from a previous form. The name of the file input is picture. Any suggestions why I get a index error for picture would be great.

PHP: Select all

<?
            
//Create Variables
            
            
$imagefile=$_FILES['picture']['tmp_name']; 
         
            
$testIt=$_POST['test'];
            
            
// Open file
            
$file fopen($imagefile"r");
            
            
// Read in the uploaded file
             
$fileContents fread($filefilesize($imagefile)); 
            
            
// Escape special characters in the file
               
$fileContents AddSlashes($fileContents);
            
            
            
//---------------Connect to database-----------------
            
$db = new mysqli('localhost''tomd''fandango''testphp');
        
            if(
mysqli_connect_errno())
            {
                echo 
'Error could not connect to database!';
                exit;
            }
                
            
$query "insert into imageIt (Image,Test) values
            ('"
.$fileContents."', '".$testIt."')";
            
            
$result $db->query($query);
            if(
$result)
            echo 
$db->affected_rows.' Record inserted into database. ';
        
            
$db->close();
                
                
?>

Last edited by sypher; Mar 20th, 2006 at 16:33.
Reply With Quote
Reply

Tags
enctype

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 20:44.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43