Hi,
I tried to insert pdf file to database actually the file uploaded into the folder name 'upload ' but cannot insert into database.
Anyone can help me to clear this issue.
- class="row">class="col-xs-8 col-xs-offset-2 well">
- enctype="multipart/form-data">
class="form-group">- "file" name="file1" />
class="form-group">- "submit" name="submit" value="Upload" class="btn btn-info"/>
- if (isset($_POST['submit']))
- {
- echo $filename = $_FILES['file1']['name'];
- // destination of the file on the server
- $destination = 'upload/' . $filename;
- // get the file extension
- $extension = pathinfo($filename, PATHINFO_EXTENSION);
- // the physical file on a temporary uploads directory on the server
- $file = $_FILES['file1']['tmp_name'];
- echo $size = $_FILES['file1']['size'];
- if (!in_array($extension, ['pdf'])) {
- echo "You file extension must be .pdf ";
- } elseif ($_FILES['myfile']['size'] > 1000000) { // file shouldn't be larger than 1Megabyte
- echo "File too large!";
- } else {
- echo 'test';
- // move the uploaded (temporary) file to the specified destination
- if (move_uploaded_file($file, $destination))
- {
- $sql = "INSERT INTO files (id,filename,created) VALUES ('1','$filename', '1')";
- if (mysqli_query($link, $sql))
- {
- echo "File uploaded successfully";
- }
- else
- {
- echo 'Failed to insiert the file.';
- }
- } else
- {
- echo "Failed to upload file.";
- }
- }
- }
karthika pommuduPosted Aug 23, 2020, 10:34 PM
Salman BegPosted Aug 9, 2020, 7:16 AM
karthika pommuduPosted Aug 6, 2020, 2:42 AM
Roshan RathodPosted Aug 5, 2020, 4:36 AM
please check this links :
https://stackoverflow.com/questions/1573581/large-pdf-files-not-uploading-to-mysql-database-as-medium-blob-via-php-files-u
https://stackoverflow.com/questions/3785754/how-to-store-a-pdf-file-in-mysql-database