Php 警告:copy():open_basedir限制生效。文件()不在允许的路径内:
我不断得到错误: 警告:copy():open_basedir限制生效。文件()不可用 在允许的路径内: 中的(/home/u590953899:/tmp:/var/tmp:/opt/php-5.5/pear) /第22行的home/u590953899/public_html/upload_rename_ac.php 第22行:Php 警告:copy():open_basedir限制生效。文件()不在允许的路径内:,php,filenames,Php,Filenames,我不断得到错误: 警告:copy():open_basedir限制生效。文件()不可用 在允许的路径内: 中的(/home/u590953899:/tmp:/var/tmp:/opt/php-5.5/pear) /第22行的home/u590953899/public_html/upload_rename_ac.php 第22行: if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)) 整个代码: <?php // Your fil
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
整个代码:
<?php
// Your file name you are uploading
$file_name = $HTTP_POST_FILES['ufile']['name'];
// random 4 digit to add to our file name
// some people use date and time in stead of random digit
$random_digit=rand(0000,9999);
//combine random digit to you file name to create new file name
//use dot (.) to combile these two variables
$new_file_name=$random_digit.$file_name;
//set where you want to store files
//in this example we keep file in folder upload
//$new_file_name = new upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
$path= "/cdn/uploads/".$new_file_name;
if($ufile !=none)
{
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
echo "Successful<BR/>";
//$new_file_name = new file name
//$HTTP_POST_FILES['ufile']['size'] = file size
//$HTTP_POST_FILES['ufile']['type'] = type of file
echo "File Name :".$new_file_name."<BR/>";
echo "File Size :".$HTTP_POST_FILES['ufile']['size']."<BR/>";
echo "File Type :".$HTTP_POST_FILES['ufile']['type']."<BR/>";
}
else
{
echo "Error";
}
}
?>
我在Stack Overflow和google上搜索了一些答案,但什么也没找到。这真的很复杂,那么我该如何解决这个问题呢?
$HTTP\u POST\u FILES
早就被弃用了。您应该使用$\u文件
和移动上传的文件()
。可能重复的请尝试此答案