I have the following code for an upload form. I am a bit confused as to what should be set for the destination of the upload. I realise that C:\data is a windows file system and I am currently testing it on OSX.
<?php
/*Script name: uploadFile.php
* Description: Uploads a file via HTTP using a POST form
*/
if(!isset($_POST['Upload']))
{
include("form_upload.inc");
} # endif
else
{
if($_FILES['pix']['tmp_name'] == "none")
{
echo "<b>File did not successfully upload. Check the file size. File must be left than 500k.<br>";
include("form_upload.inc");
exit();
}
if(!ereg("image",$_FILES['pix']['type']))
{
echo "<b>File is not a picture. Please try another file.</b><br>";
include("form_upload.inc");
exit();
}
else
{
$destination = 'c:\data' . "\\".$_FILES['pix']['name'];
$temp_file = $_FILES['pix']['tmp_name'];
move_uploaded_file($temp_file,$destination);
echo "<p><b>The file has sucessfully uploaded:</b>
{$_FILES['pix']['name']}
({$_FILES['pix']['size']})</p>";
}
}
?>
If I change c:\data to something like /library so that it is an OSX destination I get the following error -
Warning: move_uploaded_file(/Library\Picture 6.jpg): failed to open stream: Permission denied in /Library/WebServer/Documents/uploadFile.php on line 9
What am I doing wrong? Also if I wanted to change the code so that it uploaded to a server what would be the correct address to put for the destination? All I need is the file to upload to the same directory as this php file.