[Solved] can’t upload file , all element submit but the file element not

Introduction

If you are having trouble uploading a file, you are not alone. Many people have encountered this issue and have been unable to find a solution. In this article, we will discuss the common causes of this issue and provide some tips on how to resolve it. We will also provide some troubleshooting steps to help you identify the source of the problem and get your file uploaded successfully.

Solution

The most likely cause of this issue is that the file size is too large for the server to handle. Try reducing the size of the file and then uploading it again. If that doesn’t work, check the server settings to make sure that it is configured to accept the file type and size that you are trying to upload.


I’m not sure why your code is not working.. ..but can you try this form below. I have taken your form and removed all the PHP. This should still submit a file to tyo.php..

<form enctype="multipart/form-data" action="tyo.php" method="post">

    <input type="hidden" name="test"   value="123"/>
    <input type="file"   name="attac"  value="" /> 
    <input type="submit" name="submit" value="save"  />

</form>

Your code.. ..tidy’d up a bit

<form enctype = "multipart/form-data" action="tyo.php" method="POST">

    <input type="hidden" name="File_no"     value="<?= $emp_no ?>"/>
    <input type="hidden" name="date"        value="<?= $date ?>"/>
    <input type="hidden" name="day"         value="<?= $day ?>"/>
    <input type="hidden" name="record_id"   value="<?= $record_id ?>" /> 
    <input type="hidden" name="method"      value="<?= $add_absence ?>" />
    <td style="text-align:center">
        <select name="ab_ex">
        <?php
        $sql_absence = "SELECT * FROM `ex_ab_types`";
        $result_absence = $mysqli->query($sql_absence);
        if ($result_absence->num_rows > 0){
            while($row_sql_absence = $result_absence->fetch_assoc()){
                echo "<option value="$row_sql_absence[EX_ID]">$row_sql_absence[DESC]</option>";
            }
        }
        ?><select>
    </td>
    <td>
        <input type="file" name="attac"  value="" /> 
    </td>
    <td style="text-align:center">
        <input type="submit" style="margin-bottom: 0px;" value="save" class="btn btn-primary" />
    </td>
</form>

1

solved can’t upload file , all element submit but the file element not


Are you having trouble uploading a file? It can be a frustrating experience when you are trying to upload a file and it just won’t go through. Fortunately, there are a few steps you can take to troubleshoot the issue and get your file uploaded successfully.

Check Your File Size

The first thing you should do is check the size of the file you are trying to upload. Many websites have limits on the size of files that can be uploaded, so if your file is too large, it won’t be accepted. Make sure the file you are trying to upload is within the size limit.

Check Your File Type

Another common issue is that the file type you are trying to upload is not accepted. Different websites accept different file types, so make sure the file you are trying to upload is one of the accepted types. If it is not, you will need to convert it to an accepted type before you can upload it.

Check Your Internet Connection

If the file size and type are correct, the next step is to check your internet connection. If your connection is slow or unreliable, it can cause problems with uploading files. Make sure your connection is stable and that you have a good signal strength.

Check Your Browser

Finally, make sure you are using a compatible browser. Different websites may require different browsers, so make sure you are using the correct one. If you are using an outdated browser, it may not be able to handle the file you are trying to upload.

By following these steps, you should be able to successfully upload your file. If you are still having trouble, contact the website’s support team for further assistance.