PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, February 14, 2022

[FIXED] copying a file from a remote server with php copy command

 February 14, 2022     mamp, php     No comments   

Issue

I am trying to copy() a file from a remote server with the copy() command as below:

<?php

    error_reporting(E_ALL);

    $url = $_GET['url'];

    if (copy( $url, '/tmp/copy_from_url.jpeg'))
    {
        echo 'copied';
    }
?>

It seems to work as copied is displayed however there is no file to be found.

Any ideas on how I can track down the problem here?

I am running MAMP on Lion both the latest versions. The file in question is a .jpeg and allow_url_fopen is on.

Edit: the folder Applications/MAMP/tmp is actually a symbolic link to /private/tmp where the files ARE being copied but are not visible.

Is there a way to change PHP tmp folder?


Solution

If these are your permissions ls -l /tmp

lrwxr-xr-x@ 1 root wheel 11 Jul 20 23:44 /tmp -> private/tmp – ian 9 hours 

That looks like ordinary processes don't have write permission then. The last r-x means that te other users (not root or wheel group) lack the w write right. Usually Apache runs under a separate accounts, which is why PHP also cannot access it.



Answered By - mario
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing