php图像上传
但是得到这个错误 得到 那条线是php图像上传,php,file-upload,Php,File Upload,但是得到这个错误 得到 那条线是 copy($_FILES['fileField']['tmp_name'],'upload/'.$newFileName); 有什么问题吗 我的剧本是 <?php //=============Configuring Server and Database======= $host = 'localhost'; $user = 'root'; $password = ''; $database = 'DBNAME'; $conn = mysq
copy($_FILES['fileField']['tmp_name'],'upload/'.$newFileName);
有什么问题吗
我的剧本是
<?php //=============Configuring Server and Database=======
$host = 'localhost';
$user = 'root';
$password = '';
$database = 'DBNAME';
$conn = mysql_connect($host,$user,$password) or die('Server Information is not Correct');
mysql_select_db($database,$conn) or die('Database Information is not correct');
//===============End Server Configuration============
if(isset($_POST['btnAdd']))
{
$myFile = $_FILES['fileField']['name']; // Storing name into variable
//====If you want to change the name of the File====
$anyNum = rand(20,500789000); //Will generate a random number between 20and 500789000
$newFileName = $anyNum.$myFile;//===New string is concatenated====
//===Following Function will check if the File already exists========
if (file_exists("upload/".$newFileName))
{
echo $newFileName." already exists. ";
}
//======If file already exists in your Folder, It will return zero and Will not take any action===
//======Otherwise File will be stored in your given directory and Will store its name in Database===
else
{
$query = "insert into tblfileupload(file_name) values ('$newFileName')";
$res = mysql_query($query);
copy($_FILES['fileField']['tmp_name'],'upload/'.$newFileName);
//===Copy File Into your given Directory,copy(Source,Destination)
if($res>0)
{
//====$res will be greater than 0 only when File is uploaded Successfully====:)
echo 'You have Successfulluy Uploaded File';
}
}
}
?>
$\u FILES['fileField']['tmp\u name']
只包含文件名,而不是文件路径(类似于/tmp/RandomFileName
或C:\Users\xxx\AppData\Local\Temp\RandomFileName
。使用而不是复制将文件移动到您想要的目标。在“testimgupload”中是否有“upload”文件夹或者得到适当的许可。。?
<?php //=============Configuring Server and Database=======
$host = 'localhost';
$user = 'root';
$password = '';
$database = 'DBNAME';
$conn = mysql_connect($host,$user,$password) or die('Server Information is not Correct');
mysql_select_db($database,$conn) or die('Database Information is not correct');
//===============End Server Configuration============
if(isset($_POST['btnAdd']))
{
$myFile = $_FILES['fileField']['name']; // Storing name into variable
//====If you want to change the name of the File====
$anyNum = rand(20,500789000); //Will generate a random number between 20and 500789000
$newFileName = $anyNum.$myFile;//===New string is concatenated====
//===Following Function will check if the File already exists========
if (file_exists("upload/".$newFileName))
{
echo $newFileName." already exists. ";
}
//======If file already exists in your Folder, It will return zero and Will not take any action===
//======Otherwise File will be stored in your given directory and Will store its name in Database===
else
{
$query = "insert into tblfileupload(file_name) values ('$newFileName')";
$res = mysql_query($query);
copy($_FILES['fileField']['tmp_name'],'upload/'.$newFileName);
//===Copy File Into your given Directory,copy(Source,Destination)
if($res>0)
{
//====$res will be greater than 0 only when File is uploaded Successfully====:)
echo 'You have Successfulluy Uploaded File';
}
}
}
?>