What's new

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.png


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'];
 

Attachments

Last edited:
lagay mo nga to sa php code mo



ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
 
[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
 

Attachments

[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

Status
Not open for further replies.

Similar threads

Back
Top