Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Copy Files From Remote URL


how can I copy a file from a url into the directory where my php file is located?

On the server I use it is not possible to use the copy() function for this task.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Copy Uploaded File To Remote Location.
is there anyway to copy a file when uploaded through a html form. to a remote location using the copy() function?

say for instance i have my site pages on.... www.pages.com
but i want to store the uploaded files on ... www.files.com

both are on different servers can i use the same php upload script to copy the files to the remote location and store information about them in the database on localhost @ www.pages.com is this possible? or can the copy function only copy to a local location?

Error: Unable To Cache A Remote File Using Copy
I used the following code to copy a remote file to my server:

copy($URL,$cachefile);

This worked very well on my old server, but it does not work on the new one.

I am getting the following error:

Unable to open 'http://[...]' for reading: No such file or directory in /local/copyfile.php on line 23

I searched for more than two hours, but I have not found the solution.

On the php.net I found the following:

Note: As of PHP 4.3.0, both source and dest may be URLs if the "fopen wrappers" have been enabled.

I am using PHP 4.2., though I don't think that this is the reason, why it does not work.

Creating Dir, Copy Files And Pass Variables To 2 Files
I need to create a folder on the server weekly named by the user. To this folder copy the contents of an /Original folder. Inside the new folder edit one of the files to insert a data with a XML path generated in another application, copied (via memory) and pasted within the very first form and passed to the file in question.

<param name="FlashVars" value="xmlfile= $lanofile" />

the $lanofile is the value that I need to pass from the form to be read by this file.
I have created an form (n.php) that POST the name of the folder to a second file (creatdir.php) everything is cool until I have to edit the third file.

How can I pass the value of one of the formfileds to a second file and them read this value as a variable to be consumed as mentioned above? Or actually right whatever is on the third field to this position (not using variables).

Copy Files To A Different Dir?
I have a file which is located in "/usr/home/coreyr/html_files" and I want to copy it to "/usr/home/public/html" I've tried the following and I receive errors.

<?php copy('sf.html', '/usr/home/public/html'); ?>
any ideas?

Copy Files And Folders
Assuming you had a template folder and files on the webspace and you
wanted to make a exact copy/rename of it with a username and password
being the one and only difference - how would one do it ? .

(the difference being a password protected folder)

Recursive Copy Of Folder/files
I want to copy entire content(have both files and folders)from One folder to destination folder..

Copy Files And Folders From One Directory Into Another
I have files in myurl.com/myfolder

and I would like to copy all of them into

myurl.com/newfolder

I'd like to copy all of the subdirectories and files that are in
/myfolder

and I would like to be able to use a form of some sort to name the
file I want to copy, and create the folder I'd like to copy it to,
such as newfolder.

How can I use a form to create a new folder on the server?

How can I use a form to name the old folder I want to copy everything
from, then create the name of the new folder I want to copy everything
into, and then copy?

Remote Using Of Php Files
i am trying to connect a php file which has a function from another site... using this,

require("www.somesite.com/some.php");
somefuncs();

but it doesn't run it, but if i give that some.php as some.php.inc it shows the code when i try to see it... so whats the solution?

Copying Remote Files
How do i copy a picture or another file from a remote webpage, and put it into my webpage dir?

Filectime() For Remote Files?
Is there a function that will give me the same output as filectime(), on remote files?
What I'm trying to do is check the last time a remote file was modified, and if it's different from the stored time that I have for it, the file is downloaded and overwrites the local file. I've done pretty much everything except retrieving when the remote file was last modified.

Running Remote Files
My shared web hosting account does not support cron tabs. So what ive done is asked a friend who has an account that does to run a local file on his server called "mikescron.php".

I need that file to somehow open or run a file on my host. Ive seen this done with headers and also with file functions before, but i cant find any documentation on it. WOuld anyone have any suggestions or sample code. On another note does anyone have a better idea about the cron.

Reading Remote Files
I'm attempting to read a remote file and parse it for data. The problem I'm
having is that the file seems to be generated by Perl
(http://alert.dot.pima.gov/scripts/1brpssd.pl) and when I read it the
script-generated data is not displayed. When I view the page with a browser
the data is displayed just fine. I've tried using the built-in PHP commands
to read the file (file, fget) as well as the all of the Snoopy "fetch"
classes

Including Files In Remote Server
I have a perl script to grap headlines from slashdot and such for me, and I use corn to have it run hourly and put the headlines in a file on the linux server.

Now problem is that my site is sitting on a Windows 2000 Apache Server. So I can't seem to use include() to get the file into my page. Any suggestions or alternatives?

Save And Send Remote Files
I need to email linked files to email recipients, how would I
accomplish this?

I tried to download the remote file to the webserver and then attach
it to a new email message but the downloaded file headers seem to be
damaged and the file can't be used anymore (i tried both pdf and zip
files).

Could somebody help me in reading and writing the remote file to disc?
The rest should be easy...

I Can Upload Files Anywhere Except My Remote Root Folder
Im working on a project with PHP that allows users to upload pictures to my server and then reference them. After going through some uploading tutorials I have the uploading part working Except! I cant upload folders to my remote root folder. I need to allow the users to upload somewhere inside the root folder so they can reference the pictures in code after.

Just to clarify the uploading works perfectly if I put the uploads folder anywhere on my computer except the sites remote root folder (or anywhere inside the root folder)
I also beleive I am giving the folder all of the proper permissions because I am giving the uploads folder in my root directory (the one that doesnt work) the same permissions as the one outside the root (the one that works) Code:

Download Files From Remote Server To Local Webserver
I am trying to create a php page whereby people can download files from a remote server to their own server (to update their webdirectory with updated files/images etc). So for example one php page (e.g. update.php) should be able to download files from a remote server to a specific directory on their local webserver. Is this possible?

Drag Files From One Folder To Another Folder (copy) .. Possible?
Is it possible to write codings PHP or Javascript.. GUI representation
of File handling (ie. Drag files from one folder to another folder (copy)
like our windows).. pls give me some reference codings like this..

Checking "last Updated" On Remote Files.
How do I check the last updated time on remote files. I'd like my end result to be, a function that takes a list of urls, check the lastupdated date on that file (i.e., home page of someone's blog), so I can then grab the ten most recently updated among them, and print them, in descending order of update date.

Copy()
I'm trying to get this image upload function to work, and I'm stuck at a seemingly simple problem I can't solve. Here's the file with everything all-inclusive: Code:

Copy()
I am trying to copy an image to a directory. I got it working on its own, but can't get it working in the shopping cart admin area. any thoughts?

Copy Everything Between X And Y?
I'm trying to do what I figure is the opposite of preg_replace. I need to copy everything between two constant/known words in a string, e.g

$string = "I am going to the market to buy eggs and bacon for breakfast";
or
$string = "I am going to the market to buy fruit for breakfast";

How can I get 'eggs and bacon', or 'fruit', or whatever else is in between 'buy' and 'for breakfast'?

No Copy
Does anyone know how to make it to where no one can right click and copy a bunch of important data off of you page?

Copy A File From A Different Url
Hi

I am trying to copy a file froma different url but failing!

I am trying -

copy ("http://www.site.com/image.jpg" , "temp.jpg");

but getting an '

Unable to open 'http://www.olgaedwards.com/photos/2041.jpg' for reading: No such file or directory' error.

Strange because it exists and -

$file = fopen("http://www.site.com/image.jpg" , "rb");

works ok!

I even tried -

$file = fopen("http://www.site.com/image.jpg" , "rb");
copy ($file , "temp.jp");

But the same error.

Copy On Server
I think you haven't enough permission of your webserver is running. in iis an anoymous user is assigned when running a webserver. you need to change that user anoymous to a specific user and assigned that user in full permission to access your path. the system is running your php.exe ie php. so php.exe need to have full access to write or read that specific path. may be you havn't enough privilidge to read that path. check your systems security settings on this issue. apache2triad is a third party software i don't like to work in this env. try an exclusive machine and install php and webserver.

Here is the code.....

Copy A String
Im trying write a script that will do this:

I provide a directory location. The script scans all the files in a
directory, oldest to newest. In each file it looks for the word [QUOTE].
It counts forward until it finds [/QUOTE]. Then it copies the counted
characters. It opens a file titled quotes.txt and runs a scan to see if
that particular quote is in there. If it is not, it pastes it. If it is,
it drops that copied text and returns to the scan.

Im a bit stuck on the copy part. Once I find the text, how do I copy it?

Problem With Copy
I don't understand why this script want work

if($_POST['students'] == true)
copy("$file" , "/students/$file_name")
else echo "no check";

Parse error: parse error, unexpected T_ELSE

Copy From One Table To Another
I have some data in one mysql db table as such....

first_name | last_name | email | mail_type | gender | etc

I'd like to copy it into another mysql db table, but in a different order.....

id | email | first_name | last_name | gender | mail_type | etc

How would I do this with php ? A loop inserting values or something ?

Move_uploaded_file() Vs Copy()
Aside from the diffrences referenced in php.net is there anything different between copy() and move_uploaded_file() that would somehow alter uploaded files, .jpgs especially?

I have built an CMS that has worked fine for years. The public side is Flash. For certain reasons I have had to change my PHP to use move_uploaded_file() instead of copy(). Now any files I move with move_uploaded_file() make them unavailbe to Flash. When I check the server directories my .jpgs are where they are supposed to be and they are titled as expected. Also I am sure the uploaded .jpgs are not progressive.

Create/copy
what i want to do is have it when someone signs up it creates a folder with their username on the server and copyies files to that folder....

COPY Command
Currently, I have a routine with the file command, & a foreach loop to
save the file (append) to another file..

HOWEVER..

I've come accross a situation where one of my 'source' files is over
17 Megs, & my script times out... (im not echoing anything to the
screen / cron jobs...)

QUERY1 :-

I cant see anywhere if the copy command can APPEND to an existing file ?
(or does it just 'copy' - & replace whatevers there ?)

Is there any other way - that I can 'append' files together - without
timing out ?

- PS - im re-running the entire process from the start - (just in
case) - to see if the file is still 17 megs (its compiled from 900-
other files - a summary file)

Copy From One Directory To Another Using PHP
I am a novice at php and need to know how to move files from one
driectory to another on our website. I know this is an easy script but
I have no idea on how to do this.

Copy In 2 Directories
I've got a simple question.
Is it possible with the command "copy" upload a file via browser on two
different directories?

I use copy

copy("$file", "/directory1/$superdat_name")

Php Image Copy
I want to use php and copy remote images onto my server.
Reason?, well the site they are hosted on doesn't want me to direct link to the images because it costs them bandwith so they want me to save and upload to my own server only problem is there's only a couple hundrer pictures lol...
any way i can use image copy or something and copy the images to my server.

Copy A File With PHP
Im trying to copy a file from the root of my website to other folder..

$source='/home/content/maunalava/html/dev-netteampr/portales/index.php';
$destination=('/home/content/maunalava/html/dev-netteampr/portales/' . $usuario);

copy($source, $destination);

But I keep getting...failed to open stream: Is a directory in....

Copy Image
I'd like to copy a file, lock, stock and barrel to another location - copy, not move.

I was just wondering whether there's an easy way to do this using PHP. The file is a JPG image if that helps, but it makes no difference to me how it gets copied provided that it works and I understand how it happens so that I can customise the code later if necessary.

Copy Folder?
I want to copy a folder, subfolder, files, and subfiles.  I don't care about attributes. I thought about making the folder a zip, and then using extract but that was confusing and took too long on the server.

so what do I do?  Is there a script that will parse the dir and COPY all the files?

Copy Variable Name
I'm trying to create a script that creates sql insert statements dynamically. This script needs to handle several different arrays that are passed to it from various form validation scripts. The keys in these arrays are identical to the column names in their respective tables.

What I need to do is somehow output the actual names of the keys to be used as the column names in the insert statement, and then output the actual values in the array as the values to be inserted.

So I want to take an array like this:
$bookarray = array ( 'booktitle' => 'Cat In The Hat',
'price' => '15.99' );

And end up with this:

insert into books (booktitle, price) values ('Cat In The Hat', 15.99) Without knowing that the incoming keys were booktitle and price.

How To Copy An Entire Array?
can I do this? You see, I want to pass my values in to another page, but you can imagine how it would be insane to try and copy each value in the array individually

<A HREF="thepage.php?array[0]=$array[0]&array[1]=$array[1]... etc

is there a way to compress an array into a single variable, and then decompress it

like:
Code: $compressedArray = compress(0, 10, $array);
where 0 is the start index, and 10 is the end index

then when I want to use it on the other page
Code: for ($x=0; $x<=10; $x++){
$newArray[$x] = decompressMe($x, $compressedArray);
}
I'm sure that there must be some simple little thing like that.... I looked at the php manual, but couldn't really see anything like I'm talking about (or maybe I dont understand it )

Copy Command Available In Windows?
Is the copy command available for use on a windows system. I have tried to run a script using it (taken directly out of a PHP manual) and am receiving a "parse error".

Copy/Paste Anomaly
Whenever I copy and paste code from my browser into my editor of choice, then upload it to my server, the code doesn't go in right. However, if I retype the exact same code and then save the file, upload it again, it works okay. But this defeats the purpose of copy/paste.

Yes, I uploaded the file as ascii. No, there aren't any weird characters are codes that show up. I'm running MacOS 9.1 and Internet Explorer 5.0. I haven't tried copying and pasting the code on Netscape. Has anyone had this problem?

Directory Copy Question
I noticed that I can't remove the folder that I created because it says "Directory not empty" so I did a little investigation on my PC machine. I used telnet to get to my folders and did a ls -a and noticed that all of the files had an asterik on the end of them and it had a file called .gif* in there as well. So, when I deleted all the files in the folder it deleted all of them BUT the .gif* and thus I cannot delete the folder through ftp on my mac.

whew!! Finally my question:
Is this normal to have an asterik at the end of a file name when using a repetitive copy funtion like this? AND is there something wrong with my code that is forcing a file called .gif* to be created?

Here is what I have:

I am setting the variables prior to this function call.
-----------------
Calling the function like this:
getImages($sourceimagefolder,$imagepath);
------------------

Here is the function: (thanks to dusty2k by the way)
function getImages($sourceimagefolder,$imagepath) {

if ($handle = opendir($sourceimagefolder)) {

echo "Source Directory: $sourceimagefolder<br><br>";

echo "Destination Directory: $imagepath<br><br>";

echo "Files:<br><br>";

while($file = readdir($handle)) {

if($file != "." && $file != "..") {

if(copy($sourceimagefolder . $file, $imagepath . $file)) {

echo "$file copied successfully.<br>";
}
}
}

closedir($handle);

}
}

Copy() Deleted File?
I use this to upload boxart for games for my site.

Copy A File To The Server
is it possible to copy a certain given file from a set location to the server everytime the page is accessed?

I have to build a site wehere daily new information has to uploaded to an intranet server, like new exchange rates. therefore i want to build a script that automaticaly uploads a csv-file to the server whenever it is accessed. the file that has to uploaded resides(and is updated) an a certain machine on the lan. is this possible? and how would you do it? PHP Code:

Copy($file, $address)
trying to use copy($file, $address) and it throws this back at me...

Warning: open_basedir restriction in effect. File is in wrong >directory >in /home/sites/site170/web/admin/experiments/uploader.php on line 57

is this a permissions problem?

Copy Table Data To Another
I've been searching in the PHP forums for this answer, and I've found something similar, and have used to this to the problem I have.

Anyway, when I do run this script I get an error line 5 which is the 'while' statement.

$query_newsfeed = "SELECT itemid,heading,news_date,content FROM newsfeed";
$query1_exec = mysql_query ( $query_newsfeed );

// Error here!
while ( $query_row = mysql_fetch_assoc ( $query1_exec ) )
{
$query2 = "INSERT INTO newsfeed_map ( itemid,heading,news_date,content ) VALUES ( $query_row[$itemid],'$query_row[$heading]','$query_row[$news_date]','$query_row[$content]' )"
$query2_exec = mysql_query ( $query2 );

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource

Any ideas where I could be going wrong?

Copy() Japanese Characters
I use copy() in the time of file uploading. but at the time of uploading the file name change to unreadable char( my file name is in japanese char). I use win xp japanese version and php 5. So how can i upload file and keep the file name unchange in japanese char.

JPG>GIF (resizing And Saving As Copy)
I was just wondering how I take a JPG file on the server, shrink it, and save it as a copy, and in GIF format?

For example: I have a file called 'desktop.jpg', and I would like to shrink it to an image called 'desktop.gif' (based on the jpeg's name, so if it had been 'boat.jpg' it would be saved as 'boat.gif'), and resized to 120x96 pixels, and save the gif in the same directory. How do I do this?

PHP4/5 Deep Copy?
I've got a PHP4 app that I developed which I'm trying to get to run on a
PHP5 server. Everything works great, except for one thing.

There's a particular routine that creates an original object, then copies
it. (The object constructor gets some meta information from the database, so
I copy it for performance reasons). The routine then modifies the copies.

PHP5 copies by reference by default, so this doesn't work--- I'm not
modifying the copies, I'm modifying the original. I read about a trick to
create a PHP4/PHP5 compatible clone function, but that doesn't work either.
PHP5's clone is a shallow copy, so the properties of the original which are
other objects only get referenced.

// Start Example:
class simple
{
var $key;

function simple()
{}
}

class cloneable
{
var $simple;

function cloneable()
{
$this->simple = new simple();
}
}

$prototype = new cloneable();
$record1 = clone($prototype);
$record1->simple->key='blue'

$record2 = clone($prototype);
$record2->simple->key='red'

echo $record1->simple->key;
echo $record2->simple->key;
// End example

In PHP4 (assume that the clone function has been defined to just return a
copy of the original object) this code outputs "bluered". In PHP5 it
outputs "redred".

How do I deep copy an object in PHP5 the way PHP4's assignment operator
works?

File Permissions After Copy()
This function basically creates a new dir in a determined location and copies the files from an established dir to the new dir. It copies the files and creates the folder ok, bit it sets the file permissons to 755 for the new folder and file contents. I then get a 550 error if I try to delete or chmod them. Any suggestions? I get permission errors in the script if I use the chgrp and chmod functions also. PHP Code:


Copyright © 2005-08 www.BigResource.com, All rights reserved