Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9

Thread: upload error

  1. #1
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post

    upload error

    This Code keeps giving me this:
    -------
    Possible file upload attack! Here's some debugging info:
    Array
    (
    [file] => Array
    (
    [name] => opportunity_small.jpg
    [type] => image/pjpeg
    [tmp_name] => /tmp/php9AuCP2
    [error] => 0
    [size] => 19071
    )
    )

    -----------------Here's the code---------------
    PHP Code:
    <?php
    $uploaddir 
    '/www/art/';
    $uploadfile $uploaddir $_FILES['file']['name'];

    print 
    "<pre>";
    if (
    move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
       print 
    "Large Image File is valid, and was successfully uploaded. ";
       print 
    "Here's some more debugging info:\n";
       
    print_r($_FILES);
    } else {
       print 
    "Possible file upload attack!  Here's some debugging info:\n";
       
    print_r($_FILES);
    }
    print 
    "</pre>";

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    possibly ..

    $uploadfile = $uploaddir . $_FILES['file']['name'];

    should be

    $uploadfile = $uploaddir . $_FILES['userfile']['name'];
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    nope

  • #4
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    well I still think thats wrong but anyway ..

    have you given '/www/art/' the appropriate file permissions ? , I dont see what else could be wrong...

    (temporarily) try changing move_uploaded_file() for copy() , you may get a more useful error message.

    Note that move_uploaded_file() should itself print a reason it did not work perhaps error_reporting is too high.. add

    error_reporting(E_ALL);

    to the top of your script whilst testing.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #5
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    this code came right off from php.net, but i changed the directories... that's it

  • #6
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    i added error_reporting(E_ALL); and got this now:
    Warning: copy(http://narrowwaystudio.com/public_html/art/): failed to open stream: HTTP wrapper does not support writeable connections. in /home/narrow/public_html/admin/upload2.php on line 6

  • #7
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    ok, make

    $uploaddir = $_SERVER['DOCUMENT_ROOT'] . '/art/';

    (thats assuming www is part of your doc root and not a folder you have created)

    which should translate to ...
    '/home/$username/public_html/art/'; or similar
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #8
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    still same error

  • #9
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    ok 1st off what is the name of the <input type="file" name="$whats_this" ..

    ou are using both $_FILE['file'] and $_FILES['infile'] which makes no sense unless you are uploading mulltiple images ...


    anyway if this does not work then give up (changinf 'file' for 'infile' if required;

    just this & nothing else.
    PHP Code:
    <?
    move_uploaded_file
    $_FILES['file']['tmp_name'] , $_SERVER['DOCUMENT_ROOT'] . '/art/' $_FILES['file']['name'] ) ;
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

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