I ja imam problem da uploadujem sliku i da je prikažem, može pomoć ? Hvala.
Code:
$conn = mysqli_connect("localhost", "root", "");
$sql = "CREATE DATABASE IF NOT EXISTS BAZA01";
mysqli_query ($conn, $sql);
$conn = mysqli_connect("localhost", "root", "", "BAZA01");
$sql = "CREATE TABLE uploads (id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY, description CHAR(50), data (50), filename CHAR(50), filesize CHAR(50), filetype CHAR(50) )";
mysqli_query ($conn, $sql);
$data = addslashes(fread(fopen($form_data, "r"), filesize($form_data)));
$result=MYSQLi_QUERY("INSERT INTO uploads (description, data,filename,filesize,filetype) VALUES ('$form_description','$data','$form_data_name','$form_data_size','$form_data_type')");
$id= mysqli_insert_id();
echo "<p>File ID: <b>$id</b><br>";
echo "<p>File Name: <b>$form_data_name</b><br>";
echo "<p>File Size: <b>$form_data_size</b><br>";
echo "<p>File Type: <b>$form_data_type</b><p>";
$conn2 = mysqli_connect("localhost", "root","", "BAZA01");
$query = "SELECT data,filetype FROM uploads where id=$id";
$result = mysqli_query ($conn2, $query);
$data = MYSQLi_RESULT($result,0,"data");
$type = MYSQLi_RESULT($result,0,"filetype");
Header( "Content-type: $type");
print $data;
?>
<form method="post" action="#" enctype="multipart/form-data">
<input type="text" name="form_description" size="40">
<br>File to upload:<br>
<input type="file" name="form_data" size="40">
<p><input type="submit" name="submit" value="submit">
</form>
Citat:
Notice: Undefined variable: form_data in /opt/lampp/htdocs/Login/001.php on line 17
Warning: fopen(): Filename cannot be empty in /opt/lampp/htdocs/Login/001.php on line 17
Notice: Undefined variable: form_data in /opt/lampp/htdocs/Login/001.php on line 17
Warning: fread() expects parameter 1 to be resource, bool given in /opt/lampp/htdocs/Login/001.php on line 17
Notice: Undefined variable: form_description in /opt/lampp/htdocs/Login/001.php on line 18
Notice: Undefined variable: form_data_name in /opt/lampp/htdocs/Login/001.php on line 18
Notice: Undefined variable: form_data_size in /opt/lampp/htdocs/Login/001.php on line 18
Notice: Undefined variable: form_data_type in /opt/lampp/htdocs/Login/001.php on line 18
Warning: mysqli_query() expects at least 2 parameters, 1 given in /opt/lampp/htdocs/Login/001.php on line 18
Warning: mysqli_insert_id() expects exactly 1 parameter, 0 given in /opt/lampp/htdocs/Login/001.php on line 19
File ID:
Notice: Undefined variable: form_data_name in /opt/lampp/htdocs/Login/001.php on line 21
File Name:
Notice: Undefined variable: form_data_size in /opt/lampp/htdocs/Login/001.php on line 22
File Size:
Notice: Undefined variable: form_data_type in /opt/lampp/htdocs/Login/001.php on line 23
File Type:
Fatal error: Uncaught Error: Call to undefined function MYSQLi_RESULT() in /opt/lampp/htdocs/Login/001.php:28 Stack trace: #0 {main} thrown in /opt/lampp/htdocs/Login/001.php on line 28