dongnaoxia0927 2012-10-20 16:59
浏览 16

无法上传多个文件并将路径保存到数据库

Ok Basically i am following this guide which is pretty straight forward but, I am at the point now where i am completely lost. I don't want to have to start all over again and I hope it's just a minor adjustment but anyhow heres the error:

Warning: move_uploaded_file() [function.move-uploaded-file]: The second argument to     copy() function cannot be a directory in /I don't want to publicize the path name/html/add.php on line 39

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpqd62Gk' to 'thumbnails/' in /I don't want to publicize the path name/add.php on line 39
Sorry, there was a problem uploading your cover. Please check it is the appropriate size and format.
Warning: move_uploaded_file() [function.move-uploaded-file]: The second argument to copy() function cannot be a directory in /I don't want to publicize the path name/add.php on line 52

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpFVlGsv' to 'audio/' in /I don't want to publicize the path name/add.php on line 52
Sorry, there was a problem uploading your song. Please check it is the appropriate size and format. 

And here is the "add.php" which is executed after submitting the form :

<?php 
include "db_config.php";

//This is the directory where images will be saved 
$targetp = "thumbnails/"; 
$targetp = $targetp . basename( $_FILES['cover']['artist']); 

//This is our size condition 
if ($uploaded_size > 100000) 
{ 
echo "Your file is too large.<br>"; 
$ok=0; 
} 

//This is the directory where songs will be saved 
$targets = "audio/"; 
$targets = $targets . basename( $_FILES['song']['artist']); 

//This is our size condition 
if ($uploaded_size > 6000000) 
{ 
echo "Your file is too large.<br>"; 
$ok=0; 
} 

 //This gets all the other information from the form 
 $title=$_POST['title']; 
 $artist=$_POST['artist']; 
 $cover=($_FILES['cover']['artist']); 
 $song=($_FILES['song']['artist']); 
 $today = date("Ymd"); 
 $ip = $_SERVER['REMOTE_ADDR'];


 //Writes the information to the database 
 mysql_query("INSERT INTO `Thumbnails` VALUES ( '', '$artist - $title', '$cover', '', '$song', '$title', '$artist',  '$today', '$ip')") ; 

 //Writes the photo to the server 
 if(move_uploaded_file($_FILES['cover']['tmp_name'], $targetp)) 
 { 

 //Tells you if its all ok 
 echo "The file ". basename( $_FILES['cover']['artist']). " has been uploaded, and your information has been added to the directory"; 
  } 
  else { 

  //Gives and error if its not 
  echo "Sorry, there was a problem uploading your cover. Please check it is the appropriate size and format."; 
   } 

   //Duplicate for song
   if(move_uploaded_file($_FILES['song']['tmp_name'], $targets)) 
   { 

    echo "The file ". basename( $_FILES['song']['artist']). " has been uploaded, and your information has been added to the directory"; 
    } 
    else { 

    echo "Sorry, there was a problem uploading your song. Please check it is the appropriate size and format."; 
    } 
    ?> 

Perhaps a step in the right direction would be greatly appreciated as it has gotten to the point where it all feels like scribble on a screen but, I'd hate to start all over again.

  • 写回答

2条回答 默认 最新

  • douzha8489 2012-10-20 17:14
    关注

    Try to

    Change

    basename( $_FILES['cover']['artist']);
    

    To

    basename( $_FILES['cover']['name']);
    
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效