Page 1 of 1

image upload issues

Posted: Thu Feb 16, 2006 10:31 am
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

Posted: Thu Feb 16, 2006 10:42 am
by feyd
you forgot the enctype attribute in the form tag.

Code: Select all

enctype="multipart/form-data"

Posted: Thu Feb 16, 2006 11:08 am
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