Re: Upload wont work, OS X
| From: | Beth Gore | Date: | Fri, 29 Nov 2002 15:28:53 +0000 |
| Subject: | Re: Upload wont work, OS X | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-126479@lists.php.net to get a copy of this message | ||
Hi Magnus,
Your problem was you weren't using the correct part of the $_FILES array when using copy();
Cut and Past This:
if ($ok){
$res = copy($bilde_fil[tmp_name], $path."/".$nyttnavn.$ending);
print ($res)?"<b>Ferdig</b>, uploadet ".$nyttnavn.$ending."!<br>":"<b>Sorry</b>, Kunne ikke uploade.<br>";
print "<br>";
}
?>
The Important bit is the "$bilde_fil[tmp_name]" bit. This means it's copying the file from the temporary location on the server to your chosen location.
Also, as a side note, replace this too:
$MAX_FILE_SIZE = 1000000;
$bilde_fil = $_FILES['bilde_fil']; // HTTP_POST_FILES
$nyttnavn = $_POST['nyttnavn'];
$ending = $_POST['ending'];
if($bilde_fil[size] > $MAX_FILE_SIZE)
{
die("<b>Sorry</b>, Kunne ikke uploade.<br>");
}
$path="upload"; //Mappa som bildene skal havne i (husk den siste '/')
Don't set $MAX_FILE_SIZE using $_POST variables for security reasons - someone could very easily alter it in the HTML file!!!
Beth Gore
magnus nilsson wrote:
I have trouble using upload scripts - none of them work on my current config. I'vq got php 4.2.3 and global registerd = off. The problem is that the script doesnt send the variable $_FILES['my_file'] as it should. I can only upload if i hard code the filename into the script.