I am trying to get the user to upload a file and then save the file to the server using php. My code works on a non-drupal website but not on drupal. Here is my code:
<?php
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
?>
On my non drupal site, I just create a folder called upload in the root directory and the files save to it no problem. In drupal, I created an upload folder in the sites/default/files/ directory and i can't find the file. The default is the file is supposed to be saved in the root folder but i can't find it, do you know where the file is being saved? Thanks.