I have my Upload File page written in HTML/PHP. The file's content gets stored in a Blob
column of an Oracle table. The problem is that it only uploads file that is less than 2 KB and not the greator ones. The code below.
Problem:
Code only works for FileSize < 2 KB.
All these parameters are greator than 2KB.
- PHP: upload_max_filesize 2M
- PHP: post_max_size 8M
- PHP: max_input_time 60
HTML:
Please specify your file:
<form method="post" id = "myForm" name = "myForm" enctype="multipart/form-data" target="upload_target" onsubmit="startUpload();">
<p style = "text-align:center"><img align = 'middle' src = "logo.jpg" width="50%" height="100"></img></p>
<h3 align = 'center'><font color = 'orange'><u>Text File Upload</u></font></h3>
<div class = "center">
<select id = "selectPol" name = "selectPol"required >
<option value="">Please select file type</option>
<option value="choiceone">Choice One</option>
<option value="choicetwo">Choice Two</option>
</select>
</div>
<div class="center" id = "formDiv">
<br></br><input type="file" name="datafile" id = "datafile" />
<p>
<input type="submit" id = "save" name = "save" value="Upload"/>
<input type="reset" value="Reset" />
</p>
<p style = "text-align:center" id="result"></p>
</div>
<div id = "f1_upload_process" name = "f1_upload_process" style = "text-align:center; display: none;">
<span style = "text-align:center"><font color = "orange"><b>Uploading. Please wait...</b></font></span><br>
<img align = 'middle' src = "progress_bar.gif"></img>
</div>
</form>
<iframe id="upload_target" name="upload_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe>
</body>
</html>
PHP:
if(isset($_POST['save']) && $_FILES['datafile']['size'] > 0)
{
$fileName = $_FILES['datafile']['name'];
$fileSize = $_FILES['datafile']['size'];
$tmpName = $_FILES['datafile']['tmp_name'];
$fileType = $_FILES['datafile']['type'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
$conn = OCILOGON("myDB","myDB","MYSERVER");
$qry = "INSERT INTO FilesTable (date_input,file_name,File_CONTENT) VALUES (SYSDATE,'$fileName',utl_raw.cast_to_raw('$content'))";
$stmt = OCIparse($conn,$qry);
ociexecute($stmt);
$result = oci_num_rows($stmt);