note 78408 deleted from function.copy by felipe
| From: | felipe@php.net | Date: | Sun, 16 Dec 2007 12:35:29 +0000 |
| Subject: | note 78408 deleted from function.copy by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133704@lists.php.net to get a copy of this message | ||
Note Submitter: Matthew J
----
A useful use for copy is when uploading files.
getUpload( [The name given to the file element in the form], [the location to copy the upload to],
[an alternative name], [what you want the file chmod'd to] )
returns true or false.
<?php
function getUpload($name,$location,$fname='',$chmod=''){
$upload=$_FILES[$name];
if($fname==''){$fname=$upload['name'];}
if($chmod==''){$chmod="0777";}
$c=@copy($upload['tmp_name'],$location.$fname);
$m=@chmod($location.$fname,$chmod);
if(!$c||!$m){return(true);}else{return(false);}
}
?>