0

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

Attachments daniweb2.png 21.78 KB
2
Contributors
2
Replies
17
Views
3 Years
Discussion Span
Last Post by adetolaraphael
1

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']);
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.