Havning issues with file upload in php, below is the code

<html>
    <head>
        <title>margeducation</title>
    </head>
    <body>
    <p> Niggas Please upload your files in pdf or jpg format, size less than 500kbytes, capishe</p>
        <form enctype="multipart/form-data" action="processfile.php" method="post" >

               <p>REQUIRED DOCUMENTS:(Please Select all documents that were recieved for this student's application):<br/></p>

                <input type="checkbox" name="waec_scratch_card_chk" value="waec_scratch_card" />WAEC SCRATCH CARD
                <input type="hidden" name="MAX_FILE_SIZE" value="500000" />
                <input type="file" name="waec_scratch_card_file" />
                <br/>                 
                <input type="submit" name="submit" value="Process information" />              
        </form>
    </body>
</html>

process.php below

<?php


if($_FILES['waec_scratch_card_file']['type'] == "image/jpeg" || $_FILES['waec_scratch_card_file']['type'] == "application/pdf")
{
    $uploaddir ='files';            

    if (move_uploaded_file($_FILES['waec_scratch_card_file']['tmp_name'], $uploaddir))
    {
        echo "success";
    } 
    else 
    {
        echo "did not get in";
    }
}
else echo 'wrong file type nigga';
?>

Instead of the file to be uploaded into the 'files' folder in the $uploaddir it is being uploaded into an extentionless file with the name files

Please can anyone help rectify this problem

Hi,
Change this in your PHP code (line 6):

$uploaddir ='files/'.$_FILES['waec_scratch_card_file']['name'];

or

$uploaddir ='files/'.basename($_FILES['waec_scratch_card_file']['name']);

That solved my problem, thank you very much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.