Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12

Thread: Absolute Paths

  1. #1
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Absolute Paths

    Hi all,

    I'm trying to upload images to a server, but the absolute paths are creating headaches.

    right now i have: $path = "d:\nuvocreative\userimages\wheelquip\";

    But that returns as: d: uvocreative\userimages\wheelquip\ and i have to have a space after the last \ or or the " doesn't show up.

    Does anyone have any ideas?

  • #2
    Regular Coder
    Join Date
    May 2004
    Location
    sweden
    Posts
    236
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The \ is an escape character so you are unintentionally escaping the last quote. Try

    Code:
    $path = "d:\\nuvocreative\\userimages\\wheelquip\\";
    or

    Code:
    $path = "d:/nuvocreative/userimages/wheelquip/";
    At tip if you are using the sam code on a developement windows machine then uploading to a Unix/Linux machine. Use the root then append it with the path inbetween the working folder. This way the same variable will always contain the right path.

    Code:
    $path = $HTTP_SERVER_VARS['DOCUMENT_ROOT']. /directory/folder/;
    either should work.
    Last edited by carl_mcdade; 06-01-2004 at 08:30 AM.
    Carl McDade
    _____________
    Hiveminds Magazine
    for web publisher and community builders
    eRuby Tutorials

  • #3
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks.. it was $path = "d:\\nuvocreative\\userimages\\wheelquip\\";

    Now that's the first problem down, with one more to go.

    Code:
    $tmp_file = $HTTP_POST_FILES['userfile']['tmp_name'];
    $new_file = $path.$HTTP_POST_FILES['userfile']['name'];
    $res = copy($tmp_file,$new_file);
    is returning Warning: copy(d:\nuvocreative\userimages\wheelquip\commodore.jpg): failed to open stream: No such file or directory in d:\nuvocreative\clients\wheelquip\imageupload.php on line 19

  • #4
    Regular Coder
    Join Date
    May 2004
    Location
    sweden
    Posts
    236
    Thanks
    0
    Thanked 0 Times in 0 Posts
    d:\nuvocreative\userimages\wheelquip\commodor e.jpg

    The part in bold is missing ffrom your path. Assuming that

    \nuvocreative\userimages\wheelquip\ is your root directory if you use that tip I gave then all your problems should be solved.
    Carl McDade
    _____________
    Hiveminds Magazine
    for web publisher and community builders
    eRuby Tutorials

  • #5
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yer.. the file is called commodore.jpg and for some reason it had a space between the commodor and the e.jpg

    That part is fixed now, but i still get the same error.

    Warning: copy(d:\nuvocreative\userimages\wheelquip\commodore.jpg): failed to open stream: No such file or directory in d:\nuvocreative\clients\wheelquip\imageupload.php on line 19

    Ok.. i don't know why it is, but the error message doesn't have the space between the commodor and the e.jpg, but when i put it in here, it says it does..

  • #6
    Regular Coder
    Join Date
    May 2004
    Location
    sweden
    Posts
    236
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I can still see that space in the path. Close you browser and empty the cahche so that you get a fresh page. Check you filename to make sure everything is in lowercase. You might even try and rename the file and give it a go.
    Carl McDade
    _____________
    Hiveminds Magazine
    for web publisher and community builders
    eRuby Tutorials

  • #7
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    But the error isn't displaying the space until i put it in here.

    Code:
    Temp File: d:\PHP\uploadtemp\php88A.tmp
    New File: d:\nuvocreative\userimages\wheelquip\commodore.jpg
    
    Warning: copy(d:\nuvocreative\userimages\wheelquip\commodore.jpg): failed to open stream: No such file or directory in d:\nuvocreative\clients\wheelquip\imageupload.php on line 18
    Upload Failed!
    That's the whole page

  • #8
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    there is no space, i don't get what's with these forums

  • #9
    Regular Coder
    Join Date
    May 2004
    Location
    sweden
    Posts
    236
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is the folder you are trying to copy to CHMOD 777? ie. Has write previleges
    Carl McDade
    _____________
    Hiveminds Magazine
    for web publisher and community builders
    eRuby Tutorials

  • #10
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It wasn't.. and no wi'm trying to set it as that.. but i've never done it before, so i'm having trouble.. i'm going to paste the whole code in and see if someone can help me

    Code:
    <?
    $path = "d:\\nuvocreative\\userimages\\wheelquip\\";
    $max_size = 200000;
    
    chmod($path, 777);
    
    if (!isset($HTTP_POST_FILES['userfile'])) die ("No image selected."); 
    
    if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {
    
    if ($HTTP_POST_FILES['userfile']['size']>$max_size) { die("The file is too big<br>\n"); }
    if (($HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg")) {
    
    if (file_exists($path . $HTTP_POST_FILES['userfile']['name'])) { die("The file already exists<br>\n");}
    $tmp_file = $HTTP_POST_FILES['userfile']['tmp_name'];
    $new_file = $path.$HTTP_POST_FILES['userfile']['name'];
    print "Temp File: ".$tmp_file."<br>";
    print "New File: ".$new_file."<br>";
    
    $res = copy($tmp_file,$new_file);
    
    if (!isset($res)) { die("Upload Failed!<br>"); }
    echo "Upload Sucessful<br>\n";
    
    echo "File Name: ".$path.$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; }
    
    }
    ?>

  • #11
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok.. i solved it. I always do that, spend all day trying to work something out, come in to work the next morning, and i get it straight away. the folder was called "wheelquipsql", not "wheelquip".

  • #12
    Regular Coder
    Join Date
    May 2004
    Location
    sweden
    Posts
    236
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by RHolm
    Ok.. i solved it. I always do that, spend all day trying to work something out, come in to work the next morning, and i get it straight away. the folder was called "wheelquipsql", not "wheelquip".
    Happens too me more than I would like it to. This is a very big club.
    Carl McDade
    _____________
    Hiveminds Magazine
    for web publisher and community builders
    eRuby Tutorials


  •  

    Posting Permissions

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