Results 1 to 21 of 21

Thread: Upload

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    Upload

    How can I Upload this file to my website using php code

    C:\file.txt

  2. #2

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    I try

    I try That

    copy ("C:\file.jpg", "/image");

    but it does not work

    What is the error ?

  4. #4
    scoutt
    Guest
    it has to be in this form.

    PHP Code:
    if (!copy(sourcedestination)) {
        print (
    "failed to copy file...<br>\n");

    exactly, what is the error you are getting?

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    Code and Error

    I used this code

    <?

    if (!copy("C:\t\ttt.gif","./ttt.gif")) {
    print ("failed to copy file...<br>\n");
    }

    ?>


    Error:

    Warning: Unable to open 'C: tt.gif' for reading: No such file or directory in /home/vbzoom/public_html/vb-chat/copy.php on line 3
    failed to copy file

  6. #6
    scoutt
    Guest
    <?

    if (!copy("C:\t\ttt.gif","./image")) {
    print ("failed to copy file...<br>\n");
    }

    ?>
    but I am not sure why you don't want to use a form to upload the file which makes it a lot easier. I am really not positive that you can do it this way.

  7. #7
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: Code and Error

    I might be wrong, but try this:
    <?
    if (!copy("C:\\ttt.gif","./ttt.gif")) {
    print ("failed to copy file...<br>\n");
    }
    ?>
    Not the difference between it and yours.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  8. #8
    scoutt
    Guest
    ok you have to use a form. you can't upload form C: like you want.

    I just tried it and it doesn't work. probably some security thing. also you might have to have this so it knows what to do.

    <form ENCTYPE="multipart/form-data"

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    the same file

    I want to upload the same file every time I run this script without use form . I can not do that ??

    Thanks

  10. #10
    scoutt
    Guest
    well you could use the form and make the input hard coded.

    <input type=file value="C:\t\ttt.gif" name="myfile">

    something like that should work. can't see whay you would want to upload a gif once a day.

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    ok

    Thanks

  12. #12
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    for the paths thing try using

    \\t or //t instead of \t

    with the \t it might think its a tab

    hobo has the idea
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  13. #13
    scoutt
    Guest
    don't you think I have tried that. php doesn't know what is going on if it doesn't have the form headers from the form
    <form ENCTYPE="multipart/form-data"

    if the file is not in the tmp upload directory then it will not upload it. I tried all thoughs that were suggested.

    if that is the case then everytime you went to my site I could upload a win.ini form your computer and then delete it and then your computer would not start. very big secrutiy risk here.

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    is not work

    well you could use the form and make the input hard coded.

    <input type=file value="C:\t\ttt.gif" name="myfile">

    something like that should work. can't see whay you would want to upload a gif once a day



    I try that but it does not work.
    (input type=file) is not accept value

    ------
    There is any way to upload this file using my UserName and Password of my site such as FTP but using PHP CODE ??????
    Last edited by prokhaled; Apr 30th, 2002 at 05:20 AM.

  15. #15
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919

    Re: is not work

    try

    <input type=file value="C:\\t\\ttt.gif" name="myfile">

    it thinks the \t's are tabs
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    is not work

    (input type=file) is not accept any value at all.

  17. #17
    scoutt
    Guest
    then you will have to insert it everytime and do it the old fashion way.
    <form>
    <input type="file" name="userfile">
    </form>

    then you can use the copy from above.

  18. #18

  19. #19
    scoutt
    Guest
    questions on your tutorial.

    FAQ:
    Q: I want to specify a different default folder where files should be uploaded instead of the server "temp" folder -
    A: Use the "upload_tmp_dir" directive within php.ini - set it to your target folder
    that is a littel misleading. what ever you make the upload_tmp_dir is still a temp directory an dif you don't move it out within a certain time the server deletes it on cleanup.

    also $HTTP_POST_FILES is deprecated and won't be used in future versions of php as of 4.1.2 everybody should be up to that version at least do to some security issues. also in the future versions of php, register_globals will be turn off as recommended by php. so $HTTP_POST_FILES will not work and you have to use $_FILES[] to do the work.

    good tutorial otherwise...

  20. #20
    Member
    Join Date
    Apr 2002
    Posts
    52
    Originally posted by scoutt
    questions on your tutorial.


    that is a littel misleading. what ever you make the upload_tmp_dir is still a temp directory an dif you don't move it out within a certain time the server deletes it on cleanup.

    also $HTTP_POST_FILES is deprecated and won't be used in future versions of php as of 4.1.2 everybody should be up to that version at least do to some security issues. also in the future versions of php, register_globals will be turn off as recommended by php. so $HTTP_POST_FILES will not work and you have to use $_FILES[] to do the work.

    good tutorial otherwise...
    Thanks dude. Updated the tutorial with your errata. Lemme know if anything else is wrong...

  21. #21
    scoutt
    Guest
    looks good.

    The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed.
    lookk here at the very end right before the comments

    http://www.php.net/manual/en/features.file-upload.php

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