PHP error help

Discussion in 'PHP' started by axs, Jun 25, 2008.

  1. #1
    I just bought a myspace turnkey script. It has an option to upload pictures but I keep getting this error.

    Warning: array_search() [function.array-search]: Wrong datatype for second argument in /home/****/public_html/admincp/upload2.php on line 35
    Invalid image file type!
    Code (markup):
    I have no idea what this is. The instructions for the script said nothing about this.

    This is what is in line 35.
     {
      if (array_search(strtolower(substr($file['name'], strrpos($file['name'], '.')+1)), $config['ftypes']) == false) {
       echo "<B>Invalid image file type!</B>";
       exit;
      }
    Code (markup):

    Anyone have any suggestions?
     
    If someone posts a solution, use the "Best Answer" link in their post to pick it as the best answer.
    axs, Jun 25, 2008 IP
  2. 2slick

    2slick Peon

    Messages:
    73
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    check the extension of your uploaded image,

    the extension list are in this array $config['ftypes']
     
    2slick, Jun 25, 2008 Set Best Answer IP
  3. axs

    axs Guest

    Best Answers:
    0
    #3
    I tried uploading jpg gif and pngs. All say the same thing.

    Can you give me an example on how you would edit that line?
     
    axs, Jun 25, 2008 Set Best Answer IP
  4. wowla_123

    wowla_123 Peon

    Messages:
    147
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    There is error in 2nd arguement i-e $config['ftypes']. Verify the contents of this array by echoing it.
     
    wowla_123, Jun 25, 2008 Set Best Answer IP
  5. wowla_123

    wowla_123 Peon

    Messages:
    147
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Try adding the following two lines just before the if-statements.

    echo "File Types are: ".$config['ftypes'];
    exit(); 
    Code (markup):
    Your code will look like the following:

    {
    echo "File Types are: ".$config['ftypes'];
    exit();  
    if (array_search(strtolower(substr($file['name'], strrpos($file['name'], '.')+1)), $config['ftypes']) == false) {
       echo "<B>Invalid image file type!</B>";
       exit;
      }
    PHP:
    It will display value of the array. What do you get after you execute this code?
     
    wowla_123, Jun 25, 2008 Set Best Answer IP
    1 person likes this.
  6. axs

    axs Guest

    Best Answers:
    0
    #6
    I get

    But I don't see the files I uploaded.
     
    axs, Jun 25, 2008 Set Best Answer IP
  7. 2slick

    2slick Peon

    Messages:
    73
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #7
    i think it has a wrong definition on your config file, find the declaration of $config["ftypes"], in config.php

    $config['ftypes'] = array('dumb','jpg','jpeg','png','gif','bmp');
     
    2slick, Jun 26, 2008 Set Best Answer IP
    1 person likes this.
  8. axs

    axs Guest

    Best Answers:
    0
    #8
    That worked!

    Thank you.


    Rep added.
     
    axs, Jun 26, 2008 Set Best Answer IP