I upload a file to a server by filling out a form. The file should be uploaded and a record should be created with many data in the mysql table. This is how I specify the upload path:
$upload_path = "upload/";
In the public_html folder I have all the necessary .php files and the precreated upload folder as well. The upload is successful, mysql table has one new record, everything seems to be fine, except I cannot see the file in the public_html/upload folder.
I know this must be a rookie question, I need help.
$allowed_filetypes = array('.jpg','.gif','.bmp','.png','.tif','.doc','.docx','.xls','.xlsx','.pdf','.psd');
$filename = $_FILES['file']['name'];
$max_filesize = 524288; //0.5MB
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
//$upload_path = "C:/wamp/www/upload/"; //'./files/';
$upload_path = "upload/";
if(!in_array($ext,$allowed_filetypes))
{
die('The file you attempted to upload is not allowed or you haven not selected any files!');
}
if(filesize($_FILES['file']['tmp_name']) > $max_filesize)
{
die('The file you attempted to upload is too large.');
}
if(!is_writable($upload_path))
{
die('Invalid or non-writable folder');
}
if (file_exists($upload_path . $_FILES["file"]["name"]))
{
//echo $_FILES["file"]["name"] . " already exists. ";
?>
<script type="text/javascript">
alert('File with this name already exists!');
</script>
<?php
}
else
{
if(move_uploaded_file($_FILES['file']['tmp_name'],$upload_path . $filename))
{
?>
<script type="text/javascript">
alert('Successful upload!');
</script>
<?php
}
//getting variables, insert into statement -> record added to table, this part is fine
}
?>