FabioRicali.it

Copiare un file con php

by info@fabioricali.it on giu.10, 2010, under PHP

Questa funzione ci permette di copiare un file sia locale che in remoto in un altro percorso

<?php
function copyFile($source, $destination){
    if(!@copy($source,$destination)){
        $errors = error_get_last();
        $error  = $errors['type']."<br/>".$errors['message'];
        return $error;
    }else{
        return true;
    }
}
?>

Utilizzo:

<?php
copyFile("http://www.sitoremoto.it/file.txt", "./file.txt");
?>

In caso di successo torna “true” altrimenti l’errore.


Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

Archives

All entries, chronologically...