image upload issues

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
quince
Forum Newbie
Posts: 15
Joined: Tue Jul 05, 2005 10:17 am

image upload issues

Post by quince »

I don't normally use cases in functions so this is a bit new to me. I'm haveing trouble with the image upload thru these functions.

Code: Select all

case "submitImages":
        {
        echo "1";
        $path = ""; 
        $max_size = 200000;
         if (!isset($HTTP_POST_FILES['imgFileLarge'])) 
            echo "2";
            exit; 
        if (is_uploaded_file($HTTP_POST_FILES['imgFileLarge']['tmp_name'])) {
            echo "3";
             if ($HTTP_POST_FILES['imgFileLarge']['size']>$max_size) { 
                echo "The file is too big<br>\n"; 
                exit; 
            }
             if (($HTTP_POST_FILES['imgFileLarge']['type']=="image/gif") || ($HTTP_POST_FILES['imgFileLarge']['type']=="image/pjpeg") || ($HTTP_POST_FILES['imgFileLarge']['type']=="image/jpeg")) { 
                if (file_exists($path . $HTTP_POST_FILES['imgFileLarge']['name'])) { 
                    echo "The file already exists<br>\n"; 
                    exit; 
                } 
                $res = copy($HTTP_POST_FILES['imgFileLarge']['tmp_name'], $path . $HTTP_POST_FILES['imgFileLarge']['name']); 
                if (!$res) { 
                    echo "upload failed!<br>\n"; 
                    exit; 
                } else { 
                    echo "upload sucessful<br>\n";
                 } 
                echo "File Name: ".$HTTP_POST_FILES['imgFileLarge']['name']."<br>\n"; 
                echo "File Size: ".$HTTP_POST_FILES['imgFileLarge']['size']." bytes<br>\n"; 
                echo "File Type: ".$HTTP_POST_FILES['imgFileLarge']['type']."<br>\n";
             } else { 
            echo "Wrong file type<br>\n"; exit; 
            }
         }                     
        }




<form action="<?php echo $currentPage; ?>" method="post" name="pageControl">

<input type="file" name="imgFileLarge">
&nbsp;
Thumb nail:<input type="file" name="imgFileThumb"> 
&nbsp
<INPUT type='submit' class="buttons" value='Upload images' onClick="submitIt('submitImages',0);" onMouseOver="btnOvr(this);" onMouseOut="btnOvr(this);">
</form>
This is the function and the form There a bunch of other stuff going on so I omitted it, If yoou want to see the whole page let me know and I will post it, but it's over 400 lines long.


Thanks for any help you can give me!
Quince
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you forgot the enctype attribute in the form tag.

Code: Select all

enctype="multipart/form-data"
User avatar
chrys
Forum Contributor
Posts: 118
Joined: Tue Oct 04, 2005 9:41 am
Location: West Roxbury, MA (Boston)

Post by chrys »

feyd wrote:you forgot the enctype attribute in the form tag.

Code: Select all

enctype="multipart/form-data"
lol that was my guess before I even opened this thread
Post Reply