🐘 PHP Help po mysql database insert image

Status
Not open for further replies.
teka lang paps checkin ko yung code mo parang may mali dun sa $file na variable mo kasi dapat connected yun sa html sa baba eh
 
gets ko na

1613186732618.webp

name kasi ng input is file name and sa php mo naman image nakalagay

so para ma fix

yung nasa kulay green na box palitan mo ng nasa red

bale

$file = $_FILES['filename']['name'];
 
lagay mo nga to sa php code mo



ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
 
lagay mo nga to sa php code mo



ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
Ung second picture po ung output
 

Attachments

  • IMG20210213113237.webp
    IMG20210213113237.webp
    163.6 KB · Views: 25
  • IMG20210213113247.webp
    IMG20210213113247.webp
    114.5 KB · Views: 28
[CODE lang="php" title="Try"]
<?php

$conn = mysqli_connect("localhost","root","","image");

if (isset($_POST["upload"]))
{

$file = $_FILES["file"]["name"];

$sql = "INSERT into image(image) VALUES('$file')";

if(mysqli_query($conn,$sql)){

echo "File Sucessfully uploaded";
}
else{
echo "Error";
}
}

?>
<form method="post" enctype="multipart/form-data">
<label>Select File: </label>
<input type="File" name="file" size='10'>
<input type="submit" name="upload">
</form>[/CODE]

Try nyo po ito copy and paste lang.
Kapag ayaw parin gumana sa server mo may problema.
Gumagana naman po ito sakin eh.
Dapat rin po yung data type niya sa SQL naka TEXT o BLOB
Capture.PNG
 
[CODE lang="php" title="Try"]
<?php

$conn = mysqli_connect("localhost","root","","image");

if (isset($_POST["upload"]))
{

$file = $_FILES["file"]["name"];

$sql = "INSERT into image(image) VALUES('$file')";

if(mysqli_query($conn,$sql)){

echo "File Sucessfully uploaded";
}
else{
echo "Error";
}
}

?>
<form method="post" enctype="multipart/form-data">
<label>Select File: </label>
<input type="File" name="file" size='10'>
<input type="submit" name="upload">
</form>[/CODE]

Try nyo po ito copy and paste lang.
Kapag ayaw parin gumana sa server mo may problema.
Gumagana naman po ito sakin eh.
Dapat rin po yung data type niya sa SQL naka TEXT o BLOB
View attachment 1299964
Bali po ganyan kapag d ko lalagyan ng :3308 sa localhost
 

Attachments

  • IMG20210213115001.webp
    IMG20210213115001.webp
    104.8 KB · Views: 30
Status
Not open for further replies.

About this Thread

  • 49
    Replies
  • 1K
    Views
  • 7
    Participants
Last reply from:
Just1c3

Trending Topics

Online now

Members online
738
Guests online
1,378
Total visitors
2,116

Forum statistics

Threads
2,294,234
Posts
29,089,568
Members
1,207,216
Latest member
jushua1we
Back
Top