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.



 Subscribe in a reader

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

Notices


Reply
 
LinkBack Thread Tools
  #1  
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
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
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
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 09:53.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization 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