Results 1 to 8 of 8

Thread: [Resolved] Upload error

  1. #1

    Thread Starter
    Hyperactive Member naruponk's Avatar
    Join Date
    Feb 2004
    Location
    Some where in the world
    Posts
    423

    Resolved [Resolved] Upload error

    <?php
    $directory = '/public_html/';
    echo "user file = $userfile<br>\n";
    echo "user file name = $userfile_name<br>\n";
    echo "user file size = $userfile_size<br>\n";
    echo "user file type = $userfile_type<br>\n";

    if (!copy($userfile, $directory.$userfile_name)) {
    print("failed to copy $userfile...<br>\n");
    }
    if ( $userfile_type == 'text/plain' ) {

    }
    else if ( ($userfile_type == 'image/pjpeg') ||
    ($userfile_type == 'image/bmp') ||
    ($userfile_type=='image/gif') ) {
    echo "<img src=images/$userfile_name><br>\n";
    }
    ?>


    -------------------------------------

    user file = /tmp/phpC48Bsi
    user file name = hp.txt
    user file size = 15230
    user file type = application/octet-stream

    Warning: copy(/public_html/hp.txt): failed to open stream: No such file or directory in /home/ebay555/public_html/fileupload.php on line 8
    failed to copy /tmp/phpC48Bsi...


    what am i mistake?

    thanks
    Last edited by naruponk; Jun 18th, 2005 at 10:04 PM.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Upload error

    You might want to use the method described in the PHP docs instead.

    Pay special attention to the user comments, as they list a lot of possible security holes. (I found at least one of them in your code.)
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Hyperactive Member naruponk's Avatar
    Join Date
    Feb 2004
    Location
    Some where in the world
    Posts
    423

    Question Re: Upload error

    I think it may cause of permission
    if so, how can i set the permission on FTP?

    any other idea?

    thanks

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Upload error

    Depends on your FTP client. The command line client uses the chmod command.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Hyperactive Member naruponk's Avatar
    Join Date
    Feb 2004
    Location
    Some where in the world
    Posts
    423

    Re: Upload error

    Do you think my code is correct or not?

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Upload error

    I think it's a security risk, but it should work, provided that register_globals is enabled.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7
    Fanatic Member ALL's Avatar
    Join Date
    Jul 2004
    Location
    192.168.1.1
    Posts
    711

    Re: Upload error

    the problem is mostlikly NOT in the permissions... the problem is (i think) this:
    PHP Code:
    <?php 
    $directory 
    '/public_html/';
    ...
    if (!
    copy($userfile$directory.$userfile_name)) {...
    look, is there a file on the server in the location: "/public_html/blablabla.txt"? no, the file should be: "./public_html/blablabla.txt"
    chave the $directory = to:
    PHP Code:
    $directory './public_html/'
    and try it
    Please support one of my projects?
    TKForums.com

    Web Forum
    JavaScript Wiki
    ________________________
    If somone helps you, please rate their post, by clicking the to rate their post

  8. #8

    Thread Starter
    Hyperactive Member naruponk's Avatar
    Join Date
    Feb 2004
    Location
    Some where in the world
    Posts
    423

    Talking Re: [Resolved] Upload error

    I got it guys
    i set the CHMOD to 777

    thanks for all helps

Posting Permissions

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



Click Here to Expand Forum to Full Width