Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 上载多个文件并将路径保存到数据库时出现问题_Php_Mysql - Fatal编程技术网

Php 上载多个文件并将路径保存到数据库时出现问题

Php 上载多个文件并将路径保存到数据库时出现问题,php,mysql,Php,Mysql,好的,基本上我遵循这个指南,这是非常直接的,但是,我现在完全迷路了。我不想从头开始,我希望这只是一个小小的调整,但无论如何,这里有一个错误: 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.

好的,基本上我遵循这个指南,这是非常直接的,但是,我现在完全迷路了。我不想从头开始,我希望这只是一个小小的调整,但无论如何,这里有一个错误:

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. 
下面是提交表单后执行的“add.php”:

<?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."; 
    } 
    ?> 
尝试

改变

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

试一试


或者指定完整路径名,如c:/some/path/here

您得到的var\u dump($\u文件)?是否存在缩略图文件夹?否,缩略图文件夹确实存在。是否创建缩略图文件夹?但是,它已经存在了?
basename( $_FILES['cover']['name']);
 $targetp = "/thumbnails/;

 $targets = "/audio/";