Move File Path?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Barkster

    Move File Path?

    I'm trying to move some files on my server but I cannot get the path
    right. I've messed with this and can't get it right. Is there a way
    to debug the path of a file on the server? Here is what I'm trying to
    do. I have a upload.php file in root/beta/upload/upload.php and want
    to move a file in the root to root/beta/files but I get error below.
    What am I missing?

    $file = 'After.jpg';
    $newfile = '/beta/files/TestMe.jpg';

    if (!copy($file, $newfile)) {
    print "failed to copy $file...\n";
    }

    Warning: copy(After.jpg) : failed to open stream: No such file or
    directory in
    /hsphere/local/home/barkster/zipyard.com/beta/ThinUpload/TestUpload.php
    on line 5
    failed to copy After.jpg...

  • Barkster

    #2
    Re: Move File Path?

    Well I think I figured it out, it must be all relative to the upload
    file. I thought the path was relative to the root. This seems to have
    fixed it for me

    $file = '../../After.jpg';
    $newfile = '../../beta/files/TestMe.jpg';

    Comment

    • Jerry Stuckle

      #3
      Re: Move File Path?

      Barkster wrote:[color=blue]
      > Well I think I figured it out, it must be all relative to the upload
      > file. I thought the path was relative to the root. This seems to have
      > fixed it for me
      >
      > $file = '../../After.jpg';
      > $newfile = '../../beta/files/TestMe.jpg';
      >[/color]

      Or,

      $file = '/After.jpg';

      Yours is a relative path; precede it with a / to get the absolute path to root.

      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      Working...