我得到了下面的HTML表单。正如您所看到的,它正在保存一个文件。
<form enctype="multipart/form-data" action="welcome.php" method="post
"onsubmit="return validateFormOnSubmit(this)">
<b>Name</b><br/> <input type="text" name="fname" />
<br/>
<b>Description</b><br/> <TEXTAREA NAME="description" COLS=40
ROWS=6></TEXTAREA><br/><br/> <input type="hidden" name="MAX_FILE_SIZE" value="100000"/>
<b>Upload Picture</b><br/> <input name="uploadedfile" type="file" /><br />
<b>Latitude</b><br/><INPUT name="lat" id ="lat" /><br/>
<b>Longitude</b><br/><INPUT name="lng" id ="lng" /><br/> <input type="submit" />
这个文件是这样处理的...
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);其余的信息存储在SQL数据库中。我想将上传的文件存储在那个数据库中。我该如何通过发送信息的php文件来做这件事?我插入它就像..。
$query = "INSERT INTO <TABLE> (name, message, lat, lng, type)VALUES ('".$title."', '".$des."', '".$lati."', '".$long."', '".$type."')";
$q=mysql_query($query) or die(mysql_error());发布于 2010-07-21 22:10:13
如果您确实希望在MySQL DB中插入您的HTML文件,有两种方法:
但是,我的建议是将文件存储在服务器文件系统上,而不是数据库中。
发布于 2010-07-21 22:10:20
您可以通过两种方式完成此操作。
mysql_real_escape_string($data); = $data ($_file_get_contents‘file_get_contents’);$data =‘photo
然后将数据保存在字段中(您需要将该字段创建为blob)
发布于 2010-07-21 22:09:28
你是说上传文件的内容?
如下所示:
// Obtain the file content (add error handling here...)
$contents = file_get_contents($_FILES['uploadedfile']['tmp_name']);
// Escape all special characters
$contents = mysql_real_escape_string($contents)
// Do the insert
$query = 'INSERT INTO <TABLE> (....) VALUES ("' . $contents . '")';
$q=mysql_query($query) or die(mysql_error());编辑:马文是对的,它是file_get_contents。
https://stackoverflow.com/questions/3300067
复制相似问题