SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    Non-Member DelvarWorld's Avatar
    Join Date
    Jul 2004
    Location
    Baloney
    Posts
    341
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Script works on one domain but not another

    So I have a simple file uploader which allows the user to select the category for an image, then uploads the file and puts the image category into a mySQL database. Now when I developed this script for my client it worked fine on my webspace, but when I uploaded it to her site it stopped working.

    The script asks for a file location and the category, and passes the file[] array and category[] array through post. Here's the basic form:

    Code HTML4Strict:
    <input name="userfile[]" type="file" size="40" />
    Category: 
    <select name="category[]">
    <option value="1">cat 1</option>
    <option value="2">cat 2</option>
    </select>
     
    ...(there can be n forms, and the next one is identical:)
     
    <input name="userfile[]" type="file" size="40" />
    Category: 
    <select name="category[]">
    <option value="1">cat 1</option>
    <option value="2">cat 2</option>
    </select>

    And on submit it posts the arrays back to the same page (index). Now, on my site this works fine and it recieves the category array. If I do print_r($category) on MY webspace it shows that it is in fact recieiving the array. But on HER page print_r($category) returns nothing, and I've done other checks: it's not getting passed. The scripts are identical. It's passing the array of files on both sites fine, but not the category array?! Could it be different permissions..different php versions? This is really strange...

  2. #2
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    if ur uploading files, check the folder permissions for the destination, or it could be a another setting. most likely folder permission.

  3. #3
    Non-Member DelvarWorld's Avatar
    Join Date
    Jul 2004
    Location
    Baloney
    Posts
    341
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Permissions are the same. And as I said, the file array is posted fine, but the category array isn't on her domain.

  4. #4
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    are you trying to derive the form variables with $category?

    If so that sounds like a register_global issue. if you don't know - try print_r($_POST);

    Sorry if i'm off track


    oh and also just because you can pull $_FILE info doesn't mean the image is uploaded to the real folder, its still sitting in a tmp dir waiting for you to move it.

  5. #5
    Non-Member DelvarWorld's Avatar
    Join Date
    Jul 2004
    Location
    Baloney
    Posts
    341
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, looks like we're close, the working site's post looks like
    Array ( [0] => x [1] => x )

    While her site (broken) looks like:
    Array ( [MAX_FILE_SIZE] => 20000000 [category] => Array ( [0] => x [1] => x )


    But I'm unsure as to how that relates to the passing of arrays

  6. #6
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    array(array()) means 2 dimensional, because $_POST is an array, and ur categories are sent as an array.

    It looks like everything is getting passed.

    Now if you want the file info, you would do print_r($_FILES) // maybe without S i forget

  7. #7
    Non-Member DelvarWorld's Avatar
    Join Date
    Jul 2004
    Location
    Baloney
    Posts
    341
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, then how do I extract the categories array from the post data? $_POST[1] is returning nothing as well

    Edit

    WAIT
    SHUT UP
    YOU SHUT UP
    I think I got it.

    Edit 2 Yeah got it.

    Edit 3 rats too slow. But thank you immensely for your help. It's odd that they post data is different for two different sites.

  8. #8
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    it would be $_POST['categories'][0] and so on.


Bookmarks

Posting Permissions

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