PHP MySQL 将值表单到数据库


PHP MySQL form values to database

我想将所有表单值添加到我的数据库中,我知道如何插入新记录,但是我想上传的"图像",我卡住了。

插入

所有来自值并上传图像并在数据库中插入图像 url 的最简单方法是什么?

表格来源:

<form action="_eventcreate.php" id="contactform" method="POST">
<p>
<label for="event_name">Event Name:</label>
<input type="text" name="event_name" class="input" value="">
</p><p>
<label for="event_description">Description:</label>
<input type="text" name="event_description" cols="88" rows="6" class="input" value="">
</p><p>
<label for="event_date">Event Date:</label>
<input type="text" name="event_date" class="input" value="">
</p><p>
<label for="event_time">Event Time:</label>
<input type="text" name="event_time" class="input" value="">
</p><p>
<label for="event_cost">Event Cost:</label>
<input type="text" name="event_cost" class="input" value="">
</p><p>
<label for="event_image">Upload Image:</label>
<input type="file" name="fileField" id="fileField" />
</p>
<input type="submit" name="submit" value="Create Event" class="submit">                    
</form>

谢谢!

1) 使用<input type="file" name="image"/>上传。

2)在表单标签中添加:enctype="multipart/form-data"

3) 使用 $_FILES 集合获取有关上传文件的信息。

4) 使用 is_uploaded_file()move_uploaded_file() 检查文件并将其移动到最终目标。

5)确保将文件保存在可通过Web访问的目录中,并创建一个URL以将其保存在数据库中。

退房: http://www.php.net/manual/en/features.file-upload.post-method.php

chk this url

http://www.w3schools.com/php/php_file_upload.asp

你会得到一个更好的想法如何做到这一点..

您可以嵌入代码以插入带有图像名称及其其他详细信息的所有表单数据,然后再检查 $_FILES 没有错误......

尽管有许多库和框架可以管理内部结构,但您只需要调用一个函数或 2...喜欢

http://pear.php.net/HTTP_Upload

此链接可能很有用:
PHP 文件上传
使用 $_FILES["文件"]["名称"] 插入到数据库表中的"图像"字段

甚至更好的是,你可以尝试在网络上振幅可用的jQuery文件上传器,如valium-file-uploader