SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Oct 2005
    Posts
    284
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Copy Function and Relative Addresses

    There is something wrong with the parameters I provide to PHP5's copy function. And my PHP Manual search comes up with 404 for both "Copy" Function and "PHP_SELF" even for an entire-site search.

    I'm trying to render Mayank Gandhi's "Build An Automated PHP Gallery System In Minutes" (http://www.sitepoint.com/article/php...system-minutes) into an MVC presence. Here's the (I hope) relevant excerpts from the main module. (Note the PEAR convention in its classname).

    My target images folder is in lloydlegacy.net/public_html/picture/images
    Code:
    Class legacy_picture_module_Upload {
    	protected $albumId;
    	protected $photosUploaded;
    	protected $photoCaption;
    ...
     public function __Construct($pAlbumId) {
    	$this->albumId = $pAlbumId;
    	// Fetch the photo array
    	$this->photosUploaded = $_FILES['photo_filename'];
    ...
     public function PostPicture($pCaption, $pExtension, $pCounter) {
    ...
    // Build the fileName
    	$s = $_SERVER['PHP_SELF'];
    	$pos = strrpos($s, "/");
    	$filename = substr($s,0,$pos+1)."picture/images/pic".$pictureId.".".$pExtension;
    echo "<p>picture_module_Upload / PostPicture/ path <br />$filename</p>\n";
    // Store the orignal file
    echo "<p>picture_module_Upload / PostPicture/ tempname <br />
    $this->photosUploaded['tmp_name'][$pCounter]</p>\n";
    copy($this->photosUploaded['tmp_name'][$pCounter], $filename);
    and my result
    Code:
    picture_module_Upload / PostPicture/ path
    /legacy/picture/images/pic3.jpg
    
    picture_module_Upload / PostPicture/ tempname
    Array['tmp_name'][0]
    
    Warning: copy(/legacy/picture/images/pic3.jpg) [function.copy]: failed to open stream: No such file or directory in /home/lloydleg/public_html/legacy/picture/module/upload.php on line 82
    Any thoughts?

    Regards,

    Grnadpa (Grandpa) Brian

  2. #2
    SitePoint Addict
    Join Date
    Oct 2005
    Posts
    284
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Through trial and error, here is the solution
    Code:
    $path= $path= $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "legacy" . DIRECTORY_SEPARATOR . "picture" . DIRECTORY_SEPARATOR . "images" . DIRECTORY_SEPARATOR . "pic{$pictureId}.{$pExtension}";
    
    copy($this->photosUploaded['tmp_name'][$pCounter], $path);
    Grnadpa


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
  •