File uploading?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm trying to figure out how to upload an image into a MySQL database.
For some reason everything is working except the filedata.

This is what I have so far:

Database setup:
 Database - test
 Table - data(filename text not null, description text not null, filedata
longblob not null)

FileUpload.html:

<html>
<head><title>File Upload Test</title></head>
<body>

<form method='post' enctype='multipart/form-data' action='InsertData.php'>
 <p>Filename:<br>
  <input type='text' name='filename' size='40'>
 </p>
 <p>FileData:<br>
  <input type='file' name='filedata' size='40' accept='image/jpeg'>
 </p>
 <p>Description:<br>
  <textarea name='description' rows='3' cols='40'></textarea>
  <input type='submit' value='Send'>
 </p>
</form>

</body>
</html>

InsertData.php:

<?php

$FileName=$_POST['filename'];
$Description=$_POST['description'];
$FileData=$_POST['filedata'];

$Host = "127.0.0.1";
$Username = "root";
$Password = "";

$link = @mysql_connect($Host, $Username, $Password) or die ("Unable to connect
to server");

echo "Link established<br>";

mysql_select_db("test", $link) or die ("Unable to select database");

echo "Database selected<br>";

mysql_query("insert into data(filename, description, filedata) values
('$FileName', '$Description', '$FileData')");

echo "Ran Query<br>";

mysql_close($link);

echo "Link Closed<br>";
?>

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


PHP Data object relational mapping generator - http://www.meta-language.net/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 




[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux