Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6

Thread: parse error

  1. #1
    Junior Member
    Join Date
    Apr 2003
    Location
    Ottawa, ON
    Posts
    21
    Member #
    1225
    PHP Code:
    <?


    //user defined variables
    $abpath "upload"//Absolute path to where images are uploaded. No trailing slash
    $sizelim "no"//Do you want size limit, yes or no
    $size "2500000"//What do you want size limited to be if there is one
    $number_of_uploads 4;  //Number of uploads to occur

    if ($_REQUEST['submitted']){ // Begin processing portion of script

    //all image types to upload
    $cert1 "image/pjpeg"//Jpeg type 1
    $cert2 "image/jpeg"//Jpeg type 2
    $cert3 "image/gif"//Gif type
    $cert4 "image/ief"//Ief type
    $cert5 "image/png"//Png type
    $cert6 "image/tiff"//Tiff type
    $cert7 "image/bmp"//Bmp Type
    $cert8 "image/vnd.wap.wbmp"//Wbmp type
    $cert9 "image/x-cmu-raster"//Ras type
    $cert10 "image/x-x-portable-anymap"//Pnm type
    $cert11 "image/x-portable-bitmap"//Pbm type
    $cert12 "image/x-portable-graymap"//Pgm type
    $cert13 "image/x-portable-pixmap"//Ppm type
    $cert14 "image/x-rgb"//Rgb type
    $cert15 "image/x-xbitmap"//Xbm type
    $cert16 "image/x-xpixmap"//Xpm type
    $cert17 "image/x-xwindowdump"//Xwd type

    $log "";

    for (
    $i=0$i<$number_of_uploads$i++) {

        
    //checks if file exists
        
    if ($img_name[$i] == "") {
            
    $log .= "No file selected for upload $i<br>";
        }

        if (
    $img_name[$i] != "") {
            
    //checks if file exists
            
    if (file_exists("$abpath/$img_name[$i]")) {
                
    $log .= "File $i already existed<br>";
            } else {

                
    //checks if files to big
                
    if (($sizelim == "yes") && ($img_size[$i] > $size)) {
                    
    $log .= "File $i was too big<br>";
                } else {


                    
    //Checks if file is an image
                    
    if (($img_type[$i] == $cert1)
    or (
    $img_type[$i] == $cert2)
    or (
    $img_type[$i] == $cert3)
    or (
    $img_type[$i] == $cert4)
    or (
    $img_type[$i] == $cert5)
    or (
    $img_type[$i] == $cert6)
    or (
    $img_type[$i] == $cert7)
    or (
    $img_type[$i] == $cert8)
    or (
    $img_type[$i] == $cert9)
    or (
    $img_type[$i] == $cert10)
    or (
    $img_type[$i] == $cert11)
    or (
    $img_type[$i] == $cert12)
    or (
    $img_type[$i] == $cert13)
    or (
    $img_type[$i] == $cert14)
    or (
    $img_type[$i] == $cert15)
    or (
    $img_type[$i] == $cert16)
    or (
    $img_type[$i] == $cert17)) {
                        
    $size getimagesize ("$img[$i]");
                        
    $log .= "File $i width = $size[0]<br>File $i height = $size[1]<br>";
                        if (
    file_exists("$abpath/$img_name[$i]")) {
                            
    $log .= "File $i was uploaded<br>";
                        }                
                        if {
    $size[0] == 800 and $size[1] == 600){
                            @
    copy($img[$i], "$abpath/800x600/$img_name[$i]") or $log .= "Couldn't copy image 1 to server<br>";
                        } 
                        else if {
    $size[0] == 1024 and $size[1] == 768){
                            @
    copy($img[$i], "$abpath/1024x768/$img_name[$i]") or $log .= "Couldn't copy image 1 to server<br>";
                        } 
                        else if {
    $size[0] == 1280 and $size[1] == 1024){
                            @
    copy($img[$i], "$abpath/1280x1024/$img_name[$i]") or $log .= "Couldn't copy image 1 to server<br>";
                        }
                        else if {
    $size[0] == 1600 and $size[1] == 1200){
                            @
    copy($img[$i], "$abpath/1600x1200/$img_name[$i]") or $log .= "Couldn't copy image 1 to server<br>";
                        }
                        else{
                            
    $log .= "File $i is not the correct size you bastard<br>";
                        }                                        

                        } else {
                            
    $log .= "File $i is not an image<br>";
                        }
                    }
                }
            }


        }

    ?>

    <html>
    <head>
    <title>Image Report</title>
    </head>
    <body>
    <p>Log:<br>
    <?

    echo "$log";

    ?>
    </p>
    <body>
    </html>
    <? 
    exit;
    // End processing portion of script
    ?>

    <html>
    <head>
    <title>Upload Image</title>
    </head>
    <body>
    <form method=POST action=imageupload.php enctype=multipart/form-data>
    <p>Files to upload:<br>
    <? 

    for ($j=0$j<$number_of_uploads$j++) {
    ?>
    <input type=file name=img[] size=30><br>
    <?
    }
    ?>
    <input type="hidden" name="submitted" value="true">
    <input type="submit" name="submit" value="Upload"> 
    </form>
    </body>
    </html>
    http://www.experimentalsadness.com
    http://www.emosucks.net

  2.  

  3. #2
    Junior Member
    Join Date
    Apr 2003
    Location
    Ottawa, ON
    Posts
    21
    Member #
    1225
    i forget to give th error.


    Parse error: parse error, expecting `'('' in /home/jwhite/public_html/imageupload.php on line 67


    any ideas?
    http://www.experimentalsadness.com
    http://www.emosucks.net

  4. #3
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Look over your indenting braces. Make sure that the braces are on their own lines for readability.

    Also, that huge if statement is incredibly messy. I suggest you store all the mime types in an array and use in_array() to find out of a match exists.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  5. #4
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    in the following code:

    PHP Code:
        if {$size[0] == 800 and $size[1] == 600){
                                @
    copy($img[$i], "$abpath/800x600/$img_name[$i]") or $log .= "Couldn't copy image 1 to server<br>";
                            }
                            else if {
    $size[0] == 1024 and $size[1] == 768){
                                @
    copy($img[$i], "$abpath/1024x768/$img_name[$i]") or $log .= "Couldn't copy image 1 to server<br>";
                            }
                            else if {
    $size[0] == 1280 and $size[1] == 1024){
                                @
    copy($img[$i], "$abpath/1280x1024/$img_name[$i]") or $log .= "Couldn't copy image 1 to server<br>";
                            }
                            else if {
    $size[0] == 1600 and $size[1] == 1200){
                                @
    copy($img[$i], "$abpath/1600x1200/$img_name[$i]") or $log .= "Couldn't copy image 1 to server<br>"
    All your if statements have { after them, instead of a paranthesis, (
    There and Back Again :Ogre:

  6. #5
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    this is how you'd do an array as filburt suggested.

    PHP Code:
    $image_types = array (
    "image/pjpeg"//Jpeg type 1
    "image/jpeg"//Jpeg type 2
    "image/gif"//Gif type
    "image/ief"//Ief type
    "image/png"//Png type
    "image/tiff"//Tiff type
    "image/bmp"//Bmp Type
    "image/vnd.wap.wbmp"//Wbmp type
    "image/x-cmu-raster"//Ras type
    "image/x-x-portable-anymap"//Pnm type
    "image/x-portable-bitmap"//Pbm type
    "image/x-portable-graymap"//Pgm type
    "image/x-portable-pixmap"//Ppm type
    "image/x-rgb"//Rgb type
    "image/x-xbitmap"//Xbm type
    "image/x-xpixmap"//Xpm type
    "image/x-xwindowdump"  //Xwd type
    );

    and 
    to see if something is in there,

    if( 
    in_array($img_type[$i], $image_types) )
    {
        
    // is present, do something.

    There and Back Again :Ogre:

  7. #6
    Junior Member
    Join Date
    Apr 2003
    Location
    Ottawa, ON
    Posts
    21
    Member #
    1225
    thanks guys i will work on this today, and see what happens!
    http://www.experimentalsadness.com
    http://www.emosucks.net


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:30 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com