在MySQL表中存储文件路径

时间:2014-04-17 02:40:38

标签: php mysql html5-video

我正在建立一个小社交网络,以帮助自己更好地学习PHP和MySQL。一切都很好,包括上传视频的能力。视频进入我想要的文件夹。我遇到的问题是文件路径没有存储在MySQL中。我已经进行了广泛的搜索,并尝试了其他人都说过的所有内容。我已经尝试将MySQL行类型设置为varchar和text。字段名称是filePath。非常感谢帮助。如果您需要更多信息,请告诉我。  这是我的文件上传的PHP代码

if (isset($_POST['text']))
{
    $first = sanitizeString($_POST['first']);
    $last = sanitizeString($_POST['last']);
    $location = sanitizeString($_POST['location']);
    $web = sanitizeString($_POST['web']);
    $text = sanitizeString($_POST['text']);
    $text = preg_replace('/\s\s+/',' ',$text);
       $vidName = $_FILES['vid']['name'];
$vidTmp = $_FILES['vid']['tmp_name'];
$vidSize = $_FILES['vid']['size'];
$filePath = "uploadvideo/".$vidName;
move_uploaded_file($vidTmp, $filePath);

    if (mysql_num_rows(queryMysql("SELECT * FROM profiles WHERE user='$user'")))
    queryMysql("UPDATE profiles SET first='$first', last='$last', location='$location', web='$web', text='$text', filePath='$filePath'  where user='$user'");
    else queryMysql("INSERT INTO profiles VALUES('$user', '$first', '$last', '$location', '$web', '$text', '$filePath')");
}

这是我的表格

<form method='post' action='profile.php' enctype='multipart/form-data'>
<h3>Enter or edit your details and/or upload an image</h3>
<table>
<tr>
<td>
<span class='fieldname'>First Name<span style="color:#FF0000;">*</span>:</span>
</td>
<td>
<input type='text' maxlength='23' name='first' value='$first'  /><span id='info'></span></td>
</tr>
<tr>
<td>
<span class='fieldname'>Last Name<span style="color:#FF0000;">*</span>:</span>
</td>
<td>
<input type='text' maxlength='23' name='last' value='$last'  /><span id='info'></span></td>
</tr>
<tr>
<td>
<span class='fieldname'>Location:</span>
</td>
<td>
<input type='text' maxlength='30' name='location' value='$location' placeholder="ex.(City,State Country)"/><span id='info'></span></td>
</tr>
<tr>
<td>
<span class='fieldname'>Website:</span>
</td>
<td>
<input type='text' name='web' value='$web' /><span id='info'></span></td>
</tr>
<tr>
<td valign='top'>Summary of Your<br/ > Movement<br />(Limit to 200 Characters)<span style="color:#FF0000;">*</span>:</td>
<td valign='top'>
<textarea name='text' cols='50' rows='3' value='$text'>$text</textarea></td>
</tr>

</table>

_END
?>

Image: <input type='file' name='image' size='14' maxlength='32' /><br />
Video: <input type='file' name='vid' id='file' size='14' maxlength='32' /><br />
<input type='submit'  value='Save Profile' />
</form>

0 个答案:

没有答案