Php 在数据库中上载保存结果
我是PHP新手。这是我将表单结果保存到数据库和上传文件名的代码。我正在使用uploadify上传文件。 这里我有两个问题Php 在数据库中上载保存结果,php,database,scope,uploadify,Php,Database,Scope,Uploadify,我是PHP新手。这是我将表单结果保存到数据库和上传文件名的代码。我正在使用uploadify上传文件。 这里我有两个问题 文件保存在mozila中的位置,但不适用于chrome 这里有密码 if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; $picAd= $_FILES ['Filedata']['name']; //更改相同的文件名 $picAd=rand(0,1000)."_".rand(
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$picAd= $_FILES ['Filedata']['name'];
//更改相同的文件名
$picAd=rand(0,1000)."_".rand(0,1000)."_".$picAd;
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
//该行适用于所有浏览器
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
这条线不适用于chrome
// $targetFile = str_replace('//','/',$targetPath) . $picAd; <<Error for chrome
if( move_uploaded_file($tempFile,$targetFile)){ // 4
echo true;
}else{
echo false;
}
这里我没有在数据库中得到$picAd的值,它的值为空。你用谷歌搜索过吗?关于这一点,有很多好的scrpit和示例/教程;)是的,但没有任何根据我的需要,如果你有一个分享给我一个链接。是否“所有”你的其他值被插入到数据库
Null、$user'、$uname'、$pw'、$email'、$twit'
以及为什么要使用static$picAd代码>?您是否从单独的类中使用/获取此值?是,其他值正在正确保存。我没有声明它的条件外,然后它给了错误未知变量。我有一个表单和一个上传按钮,我希望表单数据和文件名保存在数据库中。
static $picAd;
if(isset($_POST['submit'])){
// varibles
$uname=$_REQUEST['userName'];
$pw=$_REQUEST["pw"];
$email= $_REQUEST["email"];
$twit= $_REQUEST["twit"];
$user="user";
if($picAd != ""){
$q="insert into users values(Null,'$user','$uname','$pw','$email','$twit','$picAd')";
mysql_query($q);
mysql_close($dbc); }
}