SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, I have this file upload skript here from Kevin's tutorial.
    But I don't know in which directory I have to upload the files to. All I know is, that my server is a unix server and on my server it looks like this here : /home/mydomain/www/mydirectory

    And this is the script :
    <?PHP
    include ("common.php");

    if ($submit) {

    if ("image/pjpeg" == $uploadedfile_type or "image/gif" == $uploadedfile_type) {

    if ("image/pjpeg" == $uploadedfile_type )
    $extension = ".jpg";
    else
    $extension = ".gif";

    $filename = "/home/myserver/www/mydirectory" . time() . $REMOTE_HOST . $extension;

    if (copy($uploadedfile, $filename)) {
    echo(" Ok, file was uploaded");
    } else {
    echo(" An error has occured");
    }

    }
    else {
    error ("Please use .gif ore .jpg");
    }
    }
    else {
    ?>
    <html>
    <head>
    <title>Untitled Document</title>
    </head>

    <body bgcolor="#FFFFFF">
    <form method="post" action="<?=$PHP_SELF?>" Enctype="multipart/form-data">
    <input type="File" name="uploadedfile">
    <input type="submit" name="submit" value="Submit">
    <input type="hidden" name="MAX_FILE_SIZE value="1024">
    </form>
    </body>
    </html>
    <?PHP
    }
    ?>


    Using this directory for the file upload ( I'm sure this is wrong ) I get the error message :
    Unable to create '/home/mydomain/www/mydirectory985121283.gif': Permission denied

    What could be wrong here. I got this "permission denied" problem in some other cases to, do I have to change some settings on my server or is there any problem with the skript ( oh sorry, it is 'script', I learned it in this forum some days ago. )
    Thanks for your help

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make sure the file

    mydirectory exists and has write permissions usually 777

    Now for your script this line here
    PHP Code:
    $filename "/home/myserver/www/mydirectory" time() . $REMOTE_HOST $extension
    You left oiut the slash after mydirectory and this line should read
    PHP Code:
    $filename "/home/myserver/www/mydirectory/" time() . $REMOTE_HOST $extension
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What exactly do you mean with :
    "write permissions usually 777 "
    I have never heard about it?

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The folder where the images will go needs to have permissions for the web server to write files into it. Since the webserver normally runs as nobody. You will most likely need to set this folder's permission to 777.


    Telnet instructions

    1) Login

    2) type this at the prompt
    chmod 777 /home/myserver/www/mydirectory/


    FTP instructions

    1) Login using cute or ws_ftp or whatever you use.

    2) right click on the directory in question and look for permissions in one of the menus or the right click menu and set it to 777
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ..wait a second...I will have a try

  6. #6
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have some problems with the speed of sitepointforums today.
    I did something called "chmod" and changed it to read,write and execute and now it is working fine.
    So now I will go on and store the location of the file in my database, that will be easy. But how can I than get this file displayed. Let's say I have a SQL Query "Select name,filelocation FROM...." then I get the filelocation, which will be something like "myfolder/12345.gif". But how can I display this file than ?

  7. #7
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Basic html my friend



    PHP Code:
    $display_path "http://mydomain.com/";

    while(.... 
    get data) {
    printf('<img src="%s">'$dislpay_path.$row["imgaename"]);

    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  8. #8
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes I knew it, I just wanted to test you :-)
    Thanks a lot, Alex

  9. #9
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Foolish smorb

    Don't you know my cat knows everything!
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  10. #10
    SitePoint Enthusiast
    Join Date
    Jan 2001
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok.... gezz! this board is cool, i was testing this form....

    How do you do this... DHTML? (the size , bold and stuff)

    Ok, to the topic.... what was it?.... oh!, ok.

    What if i want the user to upload a file .jpg or .gif only, but with the original filename?

  11. #11
    Victory shall be mine tubedogg's Avatar
    Join Date
    Mar 2001
    Location
    Medina, OH
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually the bold, italics, etc. are JavaScript and come standard with vBulletin v2.
    Kevin


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
  •