源代码如下addsong1.php:
<?php
//require("../inc/security.inc.php");
?>
<html>
<head>
<title>添加歌曲</title>
</head>
<body bgcolor="#ffffff"><font color="green">
<h1>添加歌曲first step.</h1></font>
<?php
require("../inc/admnavg.inc.php");
?>
<form method="post" action="addsong2.php" enctype="multipart/form-data">
<p>歌名:&nbsp&nbsp
<input type="text" name="song_name">
<br>
歌手:&nbsp&nbsp
<input type="text" name="singer_name">
<br>
英文名:
<input type="text" name="en_name">
<br>
文件:&nbsp&nbsp
<input type="file" name="mp3">
<br>
文件名:
<input type="text" name="file_name" value=".mp3">
<font color="red">
(此处为保存在服务器上的文件名,必须使用英文)</font><br>
M3U:&nbsp&nbsp&nbsp
<input type="text" name="play_path" value=".m3u">
<font color="red">(不需要特别改动,可不填写使用默认,必须使用英文)</font><br>
类型:&nbsp&nbsp
<select name="types">
<option value="大陆流行">大陆流行</option>
<option value="港台流行">港台流行</option>
<option value="欧美流行">欧美流行</option>
<option value="欧美乡村">欧美乡村</option>
<option value="经典歌曲">经典歌曲</option>
<option value="摇滚天堂">摇滚天堂</option>
<option value="日韩潮流">日韩潮流</option>
</select></p>
<p>
<input type="submit" name="submit" value="添加">
<input type="reset" name="submit2" value="重置">
<br>
</p>
</form>
<hr>
WING ALL COPYRIGHTS RESERVED.
</body>
</html>
addsong2.php:
<?php
//require("../inc/security.inc.php");
?>
<html>
<head>
<title>添加歌曲second step.</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
</head>
<body color="#ffffff">
<h1>添加歌曲second step.</h1>
<hr>
<?php
require("../inc/admnavg.inc.php");
?>
<b>添加结果:</b>
<?php
if($song_name==""||$singer_name=="")
{
echo "请填写完整的资料!";
exit();
}
require("../inc/condb.inc.php");
$dates=date("Y-n-j");
$sql="select * from singer where singer_name='$singer_name'";
$result=mysql_query($sql,$db_id);
if(mysql_num_rows($result)!=0)
{
$en_name=mysql_result($result,0,"en_name");
echo "歌手".$singer_name."已经村在数据库中<br>";
}
else
{
if($en_name=="")
{
echo "你没有输入歌手的英文名!";
require("../inc/closedb.inc.php");
exit();
}
$sql="insert into singer(singer_name,en_name,types) values('$singer_name','$en_name','$types')";
mysql_query($sql,$db_id);
if(is_dir($en_name)==false)
{
mkdir("../mp3/".$en_name,0700);
mkdir("../m3u/".$en_name,0700);
}
}
if($file_name=="")
{
$file_name=$mp3_name;
}$path="mp3/".$en_name."/".$file_name;
echo "mp3路径:http://192.168.1.33/music/".$path;
if($play_path!="")
{
$play_path="m3u/".$en_name."/".$play_path;
}
else
{
$play_path="m3u/".$en_name."/".str_replace(".mp3",".m3u",$file_name);
}$fp=fopen("../".$play_path,"w");
$mp3_url="http://192.168.1.33/music/".$play_path."\n\n";
fwrite($fp,$mp3_url);
fclose($fp);$sql="select singer_id from singer where singer_name='$singer_name'";
$result=mysql_query($sql,$db_id);
$singer_id=mysql_result($result,0,"singer_id");
$sql="insert into songs(song_name,singer_id,path,types,play_path,dates) values('$song_name','$singer_id','$path','$types','$play_path','$dates')";
mysql_query($sql,$db_id);
echo "<p>上传的mp3文件为:".$mp3_name;
echo "<br>保存为:".$file_name;
echo "<p>生成的m3u文件为:".$play_path;
copy($mp3,"../mp3/".$en_name."/".$file_name);
?>
<hr>
<center>
WING ALL COPYRIGHTS RESERVED.
</center>
<?php
require("../inc/closedb.inc.php");
?>
</body>
</html>

解决方案 »

  1.   

    在PHP.ini中有关于上传文件大小的限制
    upload_max_filesize = 1M
    你把它改大点,重启HTTP服务器就可以了
      

  2.   

    在PHP.ini中有关于上传文件大小的限制
    upload_max_filesize = 1M
    你把它改大点,重启HTTP服务器就可以了
      

  3.   

    Warning: Unable to open 'none' for reading是因为上传失败,可能原因(修改php.ini中的)
    1.临时路径问题:upload_tmp_dir 
    2.上传文件太大:upload_max_filesize
    3.提交数据过大:post_max_size
    4.运行时间太短:max_execution_time