Results 1 to 2 of 2

Thread: Image Upload Help

  1. #1
    Join Date
    Jan 2006
    Posts
    29
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Image Upload Help

    Hey there I currently have some code from another website that seems to be working great except one little thing. When I load it in a web browser it gives me this 'Notice: Undefined variable: PHP_SELF in' the location.

    I tried kinda 'playing' with it with no luck ill post a full section of code below.


    PHP Code:
    <?php

    echo('Upload images:


    <FORM ENCTYPE="multipart/form-data" ACTION="' 
    $PHP_SELF '" METHOD="POST">

    The file: <INPUT TYPE="file" NAME="userfile">

    <INPUT TYPE="submit" VALUE="Upload">

    </FORM>'
    );



    $path "uploaded";

    $max_size 20000;



    if (!isset(
    $HTTP_POST_FILES['userfile'])) exit;



    if (
    is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {



    if (
    $HTTP_POST_FILES['userfile']['size']>$max_size) { echo "The file is too big<br>n"; exit; }

    if ((
    $HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/png")) {



    if (
    file_exists($path $HTTP_POST_FILES['userfile']['name'])) { echo "The file already exists<br>n"; exit; }



    $res copy($HTTP_POST_FILES['userfile']['tmp_name'], $path .

    $HTTP_POST_FILES['userfile']['name']);

    if (!
    $res) { echo "upload failed!<br>n"; exit; } else { echo "upload sucessful<br>n"; }



    echo 
    "File Name: ".$HTTP_POST_FILES['userfile']['name']."<br>n";

    echo 
    "File Size: ".$HTTP_POST_FILES['userfile']['size']." bytes<br>n";

    echo 
    "File Type: ".$HTTP_POST_FILES['userfile']['type']."<br>n";

    } else { echo 
    "Wrong file type<br>n"; exit; }

    }



    $my_file $HTTP_POST_FILES['userfile']['name'];

    ?>
    Like I said the code seems to do just what it says it would and it uploads images even with the error. I just want it to go away.

    Thanks!
    - Kevin

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Which line gets the error?

    Using @function() suppresses error reporting, so if the mail() function was giving you a weird error but still working you could use @mail().

    It may also be something you could do differently, so let us know which line it is.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •