Jump to content

upload not work


inspire

Recommended Posts

i am using php 4.05 in windows . my problem is i cannot upload image inside the database.

anyone can help me solve the problem. ???

 

 

<?php

mysql_connect("localhost", "root", "") or die("no connection");

mysql_select_db("lab") or die("no database");

 

if(isset($_POST['upload']) && $HTTP_POST_FILES['userfile']['size'] > 0)

{

$fileName = $HTTP_POST_FILES['userfile']['name'];

$tmpName  = $HTTP_POST_FILES['userfile']['tmp_name'];

$fileSize = $HTTP_POST_FILES['userfile']['size'];

$fileType = $HTTP_POST_FILES['userfile']['type'];

 

$fp      = fopen($tmpName, 'r');

$content = fread($fp, filesize($tmpName));

$content = addslashes($content);

fclose($fp);

 

if(!get_magic_quotes_gpc())

{

    $fileName = addslashes($fileName);

}

 

 

 

$query = "INSERT INTO upload (name, size, type, content ) ".

"VALUES ('$fileName', '$fileSize', '$fileType', '$content')";

 

mysql_query($query) or die('Error, query failed');

 

echo "<script languange = 'Javascript'>

alert('File $fileName uploaded');

location.href = 'LMS-upload1.php';

</SCRIPT>";

}

?>

 

Link to comment
https://forums.phpfreaks.com/topic/71935-upload-not-work/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.