Jump to content

$_FILES not working


joequah1

Recommended Posts

Hi,

 

My $_FILES is not working.

Its working when Im doing my project on the local host.

After I uploaded my project to the server, the $_FILES is not working.

 

Im trying to upload images.

the $_FILES['name'] couldn't read anything. its like no file there.

 

whats causes it? any other way to read from <input type='file'/> ? or way to solve this?

 

Thank You.

Link to comment
https://forums.phpfreaks.com/topic/253459-_files-not-working/
Share on other sites

scootstah, if he has incorrect settings in php.ini, he would get FILES archive and get error code not equal to 0. I think something is wrong in his form, maybe any quote is missed or anything else.

That's why I ask TC - show code of you form.

Link to comment
https://forums.phpfreaks.com/topic/253459-_files-not-working/#findComment-1299247
Share on other sites

scootstah, if he has incorrect settings in php.ini, he would get FILES archive and get error code not equal to 0. I think something is wrong in his form, maybe any quote is missed or anything else.

That's why I ask TC - show code of you form.

 

This is true if upload_max_filesize is exceeded, but if post_max_size is exceeded then $_POST and $_FILES will be empty.

Link to comment
https://forums.phpfreaks.com/topic/253459-_files-not-working/#findComment-1299249
Share on other sites

scootstah, if he has incorrect settings in php.ini, he would get FILES archive and get error code not equal to 0. I think something is wrong in his form, maybe any quote is missed or anything else.

That's why I ask TC - show code of you form.

 

<?php require_once('includes/CssJs.php');?>

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

<input type="hidden" name="companyID" value="<?php echo $_GET['id']; ?>"/>

<?php

    require_once ('User_ControlPanel_UploadImage.php');

    $msg = array();

    $fileName = array();

    if(!empty($_POST['submitAddGallery'])){ 

        $companyID = $_POST['companyID'];

        for($int = 1 ;$int<=5;$int++)

        { 

            if(!empty($_FILES["file_$int"]['name']))

            { 

                $name = $_FILES["file_$int"]['name'];

                $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));

                $temp = str_replace(".$ext", "", $name);

                $save_as = uniqid("$temp") . '.' . $ext;

               

                $fileName[] = $save_as;

                $msg[] = uploadImage($_FILES["file_$int"],$companyID,$save_as);

            }

        }

 

        $msg = array_filter($msg);

 

        if(!empty($msg))

        {

                echo '<div id="validations-error"><ul>';

 

                foreach ($msg as $value)

                {

                    echo "<li><div class='close'>$value</div></li>";

                }

                echo '</ul></div>';

        }

        else

        {

            foreach($fileName as $value)

            {

                $displayOrder = getCount("SELECT * FROM CompanyGallery_TB WHERE CompanyID ='$companyID' ") + 1;

                       

                $Images = $companyID."/".$value;

                $sql = "INSERT INTO CompanyGallery_TB (Images,DisplayOrder,Caption,IsCover,IsDisplay,CompanyID) VALUES('$Images','$displayOrder','','No','Yes','$companyID')";

                $result = insertSQL(DB_HOST,DB_USER,DB_PASS,DB_NAME,$sql);

                echo "<script>alert('$result, ok');</script>";

            }

            $today = date("Y-m-d H:i:s");

            $sql = "UPDATE Company_TB SET updatedDate = '$today' WHERE CompanyID = '$companyID'";

            $result = insertSQL(DB_HOST, DB_USER, DB_PASS, DB_NAME, $sql);

            echo "<script>alert('Image(s) upload successfull.');</script>";

        }

    }

?>

 

<div id ="user_content" style="min-height: 100px; border:none; width: 300px;">

    <table class="list" style="width:365px;">

        <tr>

            <td colspan="3" class="title">Add Gallery</td>

        </tr>

        <tr>

            <td>Images 1</td>

            <td class="dotted">:</td>

            <td><input type="file" name="file_1"/></td>

        </tr>

        <tr>

            <td>Images 2</td>

            <td class="dotted">:</td>

            <td><input type="file" name="file_2"/></td>

        </tr>

        <tr>

            <td>Images 3</td>

            <td class="dotted">:</td>

            <td><input type="file" name="file_3"/></td>

        </tr>

        <tr>

            <td>Images 4</td>

            <td class="dotted">:</td>

            <td><input type="file" name="file_4"/></td>

        </tr>

        <tr>

            <td>Images 5</td>

            <td class="dotted">:</td>

            <td><input type="file" name="file_5"/></td>

        </tr>

    </table>

    <input type="submit" name="submitAddGallery" value="Submit" id="submitAddGallery"/>

</div>

 

</form>

 

<script type="text/javascript">

//    $("#submitAddGallery").click(

//    function () {

// parent.$.fn.colorbox.close();

//    });

</script>

Link to comment
https://forums.phpfreaks.com/topic/253459-_files-not-working/#findComment-1299252
Share on other sites

Could it because of the server settings?

 

Like I said, what is post_max_size set to in the php.ini? And how big are the files you are trying to upload?

 

i never set the post_max_size and the files im trying to upload is between 3kb to 1mb.

i tried to upload with 3kb and it don works.

 

and i tried to add in these

 

ini_set ("file_uploads","On");

    ini_set ("upload_max_filesize", "128M");

    ini_set("meemory_limit", "96M");

    ini_set("post_max_size", "64M");

 

 

it still wont work.

Link to comment
https://forums.phpfreaks.com/topic/253459-_files-not-working/#findComment-1299266
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.