Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP copy(); function problem

Featured Replies

Hi people,

 

Does anybody know why this doesn't work?

 

$img_src = 'http://www.richardscarrott.co.uk/images/projects/thumbs/tn_cp_8.jpg';
$dest = '/project/tmp_imgs/';
$status = copy($img_src, $dest) or die("Could not copy file contents");

 

I get this error:

Warning: copy(/project/tmp_imgs/) [function.copy]: failed to open stream: No such file or directory in /home/fhlinux145/r/richardscarrott.co.uk/user/htdocs/project/project.php on line 140

 

I have never used the copy(); function so may be getting the wrong end of the stick, is it actually possible to do what I am attempting?

 

Cheers

 

Rich.

  • Author

Yeah I tried that previously, but to no avail, I've tried so many variants on the path but just can't get it to work!

 

My file structure is like this:

 

 

root/project/tmp_imgs/

 

root/project/project.php

 

 

wonder if that affects the path I should be using?

 

 

incidentally what does the ./ actually mean? I've had to use it on some require_once() paths but have no idea why!

Found the problem ... you have to specify the name of the file on the destination too:

<?php
$img_src = 'http://www.richardscarrott.co.uk/images/projects/thumbs/tn_cp_8.jpg';
$dest = './tmp_imgs/temp.jpg';
$status = copy($img_src, $dest) or die("Could not copy file contents");
?>

I just tested this and it works.

  • Author

Nice one!

 

Bit odd you have to specify a name on the destination server, seems like it should default to original name and then perhaps offer a third argument to allow a change in the name.

 

Anyway thanks for your help!

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.