Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1
    Join Date
    Dec 2007
    Location
    Toronto, Ontario, Canada
    Posts
    689
    Tokens
    0

    Default Uploader not working?

    I'm just making a personal uploader out of a tutorial, and I keep getting a "file extension not alowed" error. I've tried a .psd and .png (they're both on the allowe dlist) yet it still gives me that. You can try yourself by going to: http://www.kolzy.com/upload/

    Here's my code:
    PHP Code:
    <?php

      $path 
    "upload/";
        
    $maxSize "100000";
        
    $maxWidth "1500";
        
    $maxHeight "1500";
        
    $allowedExt ".gif,.bmp,.png,.jpg,.zip,.psd";
        
            function 
    get_ext($file){
          
    $ex strstr($file,".");
          return 
    $ex;
        }
        
        if (!
    $_POST['submit']){
        
    ?>
          <form method="post" action="" enctype="multipart/form-data">
            <label>Select Image</label><br />
              <input name="image_file" type="file"><br />
              <input name="submit" type="submit" value="Upload">
            </form>
            
            <?php
            
    }
            
            else{
          
    $file $_FILES['image_file'];
          
          if(
    $file == NULL){
              echo 
    "No image selected.";

            }else{
              
    $random rand(0,9999);
                
    $random *= rand(0,9999);
                
    $random *= rand(0,9999);
                
    $random /= 3;
                
                
    $file_name $random."-".basename($_FILES['image_file']['name']);
                
    $up_path $path.$file_name;
                
    $ext get_ext($file);
                
                list(
    $width$height$ftype$attr) = getimagesize($_FILES['image_file']['tmp_name']);
                
    $fileExt explode(",",$allowedExt);
                
                            if (
    $width $maxWidth){
                  echo 
    "The width of the image can only be: ".$maxWidth."px";
                }elseif (
    $height $maxHeight){
                  echo 
    "The height of the image can only be: ".$maxHeight."px";

                }elseif (!
    in_array($ext,$fileExt)){
                  echo 
    "File extention not recognized.<br /> Allowed extentions: ".$allowedExt;

                }else{
                  if(
    move_uploaded_file($file_name,$up_path)){

                    }else{
                        echo 
    "Error with uploading the image.";

                    }
                }
            }
        }
    ?>

  2. #2
    Join Date
    Sep 2007
    Location
    Blackpool
    Posts
    8,200
    Tokens
    0

    Latest Awards:

    Default

    Hmm I got the same message -

    "File extention not recognized.
    Allowed extentions: .gif,.bmp,.png,.jpg,.zip,.psd"

    Although I can't see anything wrong with the code (although I'm not an expert so there may be) sorry I wasn't much help.
    Last edited by Slowpoke; 05-06-2008 at 12:43 AM.

  3. #3
    Join Date
    May 2007
    Location
    Brisbane, Australia
    Posts
    796
    Tokens
    0

    Default php

    uhhm try this:

    PHP Code:
     <?php

      $path 
    "upload/";
        
    $maxSize "100000";
        
    $maxWidth "1500";
        
    $maxHeight "1500";
        
    $allowedExt ".gif, .bmp, .png, .jpg, .zip, .psd";
        
            function 
    get_ext($file){
          
    $ex strstr($file,".");
          return 
    $ex;
        }
        
        if (!
    $_POST['submit']){
        
    ?>
          <form method="post" action="" enctype="multipart/form-data">
            <label>Select Image</label><br />
              <input name="image_file" type="file"><br />
              <input name="submit" type="submit" value="Upload">
            </form>
            
            <?php
            
    }
            
            else{
          
    $file $_FILES['image_file'];
          
          if(
    $file == NULL){
              echo 
    "No image selected.";

            }else{
              
    $random rand(0,9999);
                
    $random *= rand(0,9999);
                
    $random *= rand(0,9999);
                
    $random /= 3;
                
                
    $file_name $random."-".basename($_FILES['image_file']['name']);
                
    $up_path $path.$file_name;
                
    $ext get_ext($file);
                
                list(
    $width$height$ftype$attr) = getimagesize($_FILES['image_file']['tmp_name']);
                
    $fileExt explode(",",$allowedExt);
                
                            if (
    $width $maxWidth){
                  echo 
    "The width of the image can only be: ".$maxWidth."px";
                }elseif (
    $height $maxHeight){
                  echo 
    "The height of the image can only be: ".$maxHeight."px";

                }elseif (!
    in_array($ext,$fileExt)){
                  echo 
    "File extention not recognized.<br /> Allowed extentions: ".$allowedExt;

                }else{
                  if(
    move_uploaded_file($file_name,$up_path)){

                    }else{
                        echo 
    "Error with uploading the image.";

                    }
                }
            }
        }
    ?>
    Thanks,
    Chris
    Free Image Uploading

    __________________


    [/url]

    [/FONT]

  4. #4
    Join Date
    Dec 2007
    Location
    Toronto, Ontario, Canada
    Posts
    689
    Tokens
    0

    Default

    That didn't work Chris, thanks boith of you.

  5. #5
    Join Date
    May 2007
    Location
    Brisbane, Australia
    Posts
    796
    Tokens
    0

    Default mhm

    Then try getting rid of the "." with the extensions
    Thanks,
    Chris
    Free Image Uploading

    __________________


    [/url]

    [/FONT]

  6. #6
    Join Date
    Dec 2007
    Location
    Toronto, Ontario, Canada
    Posts
    689
    Tokens
    0

    Default

    I've tried that already, it didn't work.

  7. #7
    Join Date
    Dec 2007
    Location
    Toronto, Ontario, Canada
    Posts
    689
    Tokens
    0

    Default

    Anybody?

    Edited by Kaotix12 (Forum Moderator): Please do not double post in order to bump your thread.
    Last edited by Ashley; 05-06-2008 at 03:40 PM.

  8. #8
    Join Date
    Dec 2007
    Location
    Toronto, Ontario, Canada
    Posts
    689
    Tokens
    0

    Default

    I really need help with this, does anybody know what's up with it? +rep to anyone who helps.

    Edited by Kaotix12 (Forum Moderator): Please do not double post in order to bump your thread.
    Last edited by Ashley; 05-06-2008 at 09:25 PM.

  9. #9
    Join Date
    May 2008
    Location
    Cheshire
    Posts
    133
    Tokens
    0

    Default

    try this:
    PHP Code:
    <?php

      $path 
    "uploads/";
        
    $maxSize "100000";
        
    $maxWidth "1500";
        
    $maxHeight "1500";
        
    $allowedExt = array('jpg''gif''png''zip''psd');;
        
            function 
    get_ext($file){
          
    $ex strstr($file,".");
          return 
    $ex;
        }
        
        if (!
    $_POST['submit']){
        
    ?>
          <form method="post" action="" enctype="multipart/form-data">
            <label>Select Image</label><br />
              <input name="image_file" type="file"><br />
              <input name="submit" type="submit" value="Upload">
            </form>
            
            <?php
            
    }
            
            else{
          
    $file $_FILES['image_file'];
          
          if(
    $file == NULL){
              echo 
    "No image selected.";

            }else{
              
    $random rand(0,9999);
                
    $random *= rand(0,9999);
                
    $random *= rand(0,9999);
                
    $random /= 3;
                
                
    $file_name $random."-".basename($_FILES['image_file']['name']);
                
    $up_path $path.$file_name;
                
    $ext get_ext($file);
                
                list(
    $width$height$ftype$attr) = getimagesize($_FILES['image_file']['tmp_name']);
                
    $fileExt explode(",",$allowedExt);
                
                            if (
    $width $maxWidth){
                  echo 
    "The width of the image can only be: ".$maxWidth."px";
                }elseif (
    $height $maxHeight){
                  echo 
    "The height of the image can only be: ".$maxHeight."px";

                }elseif (!
    in_array($ext,$fileExt)){
                  echo 
    "File extention not recognized.<br /> Allowed extentions: ".$allowedExt;

                }else{
                  if(
    move_uploaded_file($file_name,$up_path)){

                    }else{
                        echo 
    "Error with uploading the image.";

                    }
                }
            }
        }
    ?>
    Thanks
    Last edited by CoolHostUK-Dom; 05-06-2008 at 09:26 PM.

  10. #10
    Join Date
    Jul 2005
    Location
    Cymru! :o Bahh
    Posts
    571
    Tokens
    0

    Default

    at above, it would give this error;

    File extention not recognized.
    Allowed extentions: Array

    Was the first thing i tried when i attempted to fix the code.

    So A Kiss Is Out Of The Question Then..?

    ♥ My Boy <sinlge> Tbh ♥
    This love isn't good unless it's me and you
    Complicated is the whole point. x

    Theres nothing scarier than getting something you want because then you have something to lose..





Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •