We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

[2892] Uploading files in PHP

Last post 09-28-2006 11:08 AM by CarlBe. 34 replies.
Page 1 of 3 (35 items) 1 2 3 Next >
Sort Posts: Previous Next
  • 01-01-1999 12:00 AM

    [2892] Uploading files in PHP

    This thread is for discussions of Uploading files in PHP.

    • Post Points: 135
  • 09-12-2002 5:48 AM In reply to

    • collinong
    • Not Ranked
    • Joined on 09-12-2002
    • United States
    • New Member
    • Points 5

    file ownership?

    when a partner wrote a simple script to receive uploaded files, the owner of the file was set to nobody, which is the apache webserver, I believe.
    In this case, we can't access or manipulate the uploaded files via ftp or the shell.  Chmod doesn't seem to work.

    Are we doing something wrong or is this always the case?

    Thanks,
    Collin
    • Post Points: 0
  • 02-03-2003 4:24 AM In reply to

    • pautasso
    • Not Ranked
    • Joined on 02-03-2003
    • New Member
    • Points 20

    php upload files

    Hi,
    I'm a new inexpert php programmer.

    I've tested your script upload.html and upload.php and it is all  ok.

    Now, I like modify script to upload a specified file (i.e c:\pippo.ttt) from pc to server, without insert manually the file name in the input box, but I have some problems.


    test 1)
    I try to substitute in upload.htm the line:
    :---------
      submit this file: <input type=file name="userfile"><br>
    :---------
    with this line :
    :---------
      submit this file: <input type="hidden" name="userfile" value="cippo.ttt"><br>
    :---------
    ... but the server ( http://infrarossi.free.fr/test/upload5.htm ) replay :
    :---------
    Warning: Unable to open 'cippo.ttt' for reading: No such file or directory in your script on line 12
    :---------



    --------------------------------------------------------------
    test 2)
    to debug I add a line in upload.php
    :---------
       echo "$userfile";
       echo "<br>-xxx-<br>";
    :---------
    ... but the server replay:

    :---------
    ./phpIV1Asq
    -xxx-

    Warning: Unable to open 'cippo.ttt' for reading: No such file or directory in your script on line 9
    :---------


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


    The question:

    Why the string cippo.ttt is echoed as ./phpIV1As ?

    Thank you for your help.

    Best regards
    • Post Points: 0
  • 02-03-2003 4:25 AM In reply to

    • pautasso
    • Not Ranked
    • Joined on 02-03-2003
    • New Member
    • Points 20

    php upload files

    Hi,
    I'm a new inexpert php programmer.

    I've tested your script upload.html and upload.php and it is all  ok.

    Now, I like modify script to upload a specified file (i.e c:\pippo.ttt) from pc to server, without insert manually the file name in the input box, but I have some problems.


    test 1)
    I try to substitute in upload.htm the line:
    :---------
      submit this file: <input type=file name="userfile"><br>
    :---------
    with this line :
    :---------
      submit this file: <input type="hidden" name="userfile" value="c:pippo.ttt"><br>
    :---------
    ... but the server ( http://infrarossi.free.fr/test/upload5.htm ) replay :
    :---------
    Warning: Unable to open 'c:pippo.ttt' for reading: No such file or directory in your script on line 12
    :---------



    --------------------------------------------------------------
    test 2)
    to debug I add a line in upload.php
    :---------
       echo "$userfile";
       echo "<br>-xxx-<br>";
    :---------
    ... but the server replay:

    :---------
    ./phpIV1Asq
    -xxx-

    Warning: Unable to open 'c:pippo.ttt' for reading: No such file or directory in your script on line 9
    :---------


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


    The question:

    Why the string c:pippo.ttt is echoed as ./phpIV1As ?

    Thank you for your help.

    Best regards
    • Post Points: 0
  • 02-04-2003 9:20 PM In reply to

    I have a little prob

    I am new php programmer but when I test your upload php. I got a message

    Warning: Unable to create '/home/www/phptest/test.txt': Permission denied in /home/www/phptest/upload.php on line 6
    file uploaded

    instead. what should I do to solve this prob?
    • Post Points: 0
  • 02-05-2003 3:22 AM In reply to

    • pautasso
    • Not Ranked
    • Joined on 02-03-2003
    • New Member
    • Points 20
    Try on a php supported server (i.e. sign up on www.free.fr)  
    bye
    • Post Points: 0
  • 02-06-2003 2:13 AM In reply to

    • S.S. Ahmed
    • Not Ranked
    • Joined on 01-01-1970
    • United States
    • New Member
    • Points 15
    Hi

    Run your application from the "public" folder under your server's root directory.

    S.S
    S.S. Ahmed
    Web: www.walisystems.com
    Blog: www.sharepointblogs.com/ssa
    • Post Points: 0
  • 02-18-2003 2:59 AM In reply to

    • vkson
    • Not Ranked
    • Joined on 02-18-2003
    • New Member
    • Points 5

    support tech

    are you talking to me?
    • Post Points: 0
  • 02-26-2003 6:32 AM In reply to

    • meissi
    • Not Ranked
    • Joined on 02-26-2003
    • New Member
    • Points 20

    About empty input field..

    Hi!

    I used this code for my upload form and worked ok...there's just something i can't get to work.
    I placed a check for the "empty input field" and I can't get it to work.

    <html>
    <?
    if(!empty($userfile)) {
    copy($userfile, "kuva.gif");
    echo("file uploaded");
    }
    else {
    echo("FAILED!");
    }
    ?>
    </html>

    No matter if I turn the code "upside down", it only does the "if" part..can you help me?

    -meissi-
    • Post Points: 0
  • 03-24-2003 11:42 PM In reply to

    • wewill
    • Not Ranked
    • Joined on 03-24-2003
    • New Member
    • Points 5

    How do in the "no my server"?

    That's so easy in my self server, but I am using free hosting like iwebland.com.
    May I change temporary directory? no I think so.
    I tried do a copy inside my root, and I discover that I haven't permision to do that.
    I don't know java.
    I can't use ftp because I can't give the access to my customer, but he need put images in the database.
    May redirect the upload trought "<input type=file..." to the directory in my root?
    • Post Points: 0
  • 04-06-2003 1:25 PM In reply to

    Reply

    I have a little prob
    I am new php programmer but when I test your upload php. I got a message

    Warning: Unable to create '/home/www/phptest/test.txt': Permission denied in /home/www/phptest/upload.php on line 6
    file up...


    You need to make sure the directory you are uploading to has write permissions. If it doesn't you will get that error!
    • Post Points: 0
  • 04-08-2003 5:39 AM In reply to

    • alirees
    • Not Ranked
    • Joined on 04-08-2003
    • New Member
    • Points 5
    I have had this problem before.  Your code appears to be ok so it seems odd that it is not working.  Try using the same code but without the braces {} - this often helps me in PHP when for some reason the second branch of the conditional is never reached.



    Quote:
    [1]Posted by meissi on 26 Feb 2003 06:32 AM[/1]
    Hi!

    I used this code for my upload form and worked ok...there's just something i can't get to work.
    I placed a check for the "empty input field" and I can't get it to work.

    <html>
    <?
    if(!empty($userfile)) {
    copy($userfile, "kuva.gif");
    echo("file uploaded");
    }
    else {
    echo("FAILED!");
    }
    ?>
    </html>

    No matter if I turn the code "upside down", it only does the "if" part..can you help me?

    -meissi-
    • Post Points: 0
  • 06-09-2003 7:54 PM In reply to

    • Cheeseh
    • Not Ranked
    • Joined on 06-09-2003
    • New Member
    • Points 30

    Answer

    Quote:
    ...I am new php programmer but when I test your upload php. I got a message

    Warning: Unable to create '/home/www/phptest/test.txt': Permission denied in /home/www/phptest/upl


    *bonk on head*

    Perhaps you don't have a www/phptest/ folder

    The text "'/home/www/phptest/test.txt" was just an example, you can make it anything you want, as long as its a valid place in your webspace.
    • Post Points: 0
  • 06-09-2003 7:59 PM In reply to

    • Cheeseh
    • Not Ranked
    • Joined on 06-09-2003
    • New Member
    • Points 30
    "./phpIV1As" sounds like a directory name, probably the directory of your php folder or where your files are stored on your webspace, which may be inaccessable to you.

    With your "c:pippo.ttt" file name, have you tried putting in the "\" backspace after C: in this text? If you don't, which is what you have done here, then PHP will look for the pippo.ttt file in the present working directory of the C: Drive, which is unnecessarily the root folder of the C: drive.
    • Post Points: 0
  • 06-09-2003 8:02 PM In reply to

    • Cheeseh
    • Not Ranked
    • Joined on 06-09-2003
    • New Member
    • Points 30
    Perhaps it's more likely that the data getting put into $userfile is not working properly leaving it empty.

    I'd also rather have "<?php" instead of just "<?" when starting to write php code.

    <?php

    if(!empty($userfile))
    {
     copy($userfile, "kuva.gif");
     echo("file uploaded");
    }
    else
    {
     echo("FAILED!");
    }

    ?>
    • Post Points: 0
Page 1 of 3 (35 items) 1 2 3 Next >