so i have a form that will let users upload certain files to my website (server), and I've been trying to figure out a way to upload the file the user has submitted (and all of its contents) to my server successfully.
Here is what I've tried so far:
(My form)
<form action="index.php" method="post">
Select File:<br/>
<input type="file" name="file" id="fileID" accept=".ff"><br/>
<input type="submit" name="submitfile" value="Upload"/>
</form>
(My PHP)
if(isset($_POST['submitfile']))
{
$GetFileextension=$_POST['file'];
if(end(explode('.', $GetFileextension))=="ff")
{
$usrU = fopen($_POST['file'], "w"); //Attempt to upload file
}
else
{
echo "Error: unsupported file type"; //File type is unsupported
}
}
The problem is that all this will do is upload the file to my server but it doesn't contain any of the file contents.
For example if i had a file name something like example.ff
and i use the above script to try to upload the file, all it will do is create a file in my server named example.ff
BUT the file in my server will not contain example.ff
original contents.
What am i doing wrong? Am i uploading the file incorrectly or something?