Php 移动上传的文件

Php 移动上传的文件,php,file,upload,Php,File,Upload,我有一个有3个标签的表单,一个用于图片,一个用于音乐,一个用于youtube。 前两种是人们可以上传文件的表单,第二种只是用于youtube链接 当人们点击“上传”按钮时,他们会被发送到第二个页面,在那里完成实际的上传。现在上传musc是可行的,但是使用相同的代码来上传图片似乎不可行 if (isset($_POST['submitfoto'])) { // uploaden $target_path = "uploads/"; $target_path = $targe

我有一个有3个标签的表单,一个用于图片,一个用于音乐,一个用于youtube。 前两种是人们可以上传文件的表单,第二种只是用于youtube链接

当人们点击“上传”按钮时,他们会被发送到第二个页面,在那里完成实际的上传。现在上传musc是可行的,但是使用相同的代码来上传图片似乎不可行

if (isset($_POST['submitfoto'])) {
    // uploaden
    $target_path = "uploads/";
    $target_path = $target_path . time() . $_SERVER['REMOTE_ADDR'] . basename( $_FILES['uploadedfile']['name']); 
    if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {

    // Here I do a bunch of stuff with the database, but it never gets that far.    
    echo "Thanks for uploading this file.";

    } else{ echo "File upload failed";} }
现在我得到文件上传失败的所有时间。但是,上传.mp3文件时似乎使用了完全相同的代码


这是怎么可能的?

试着检查一下$\u文件['uploadedfile']['error']有什么?在你的
块中$\u文件['uploadedfile']['error']
显示了什么?@JoseVega-伟大的思想都是一样的!或者……也许是因为我们在用PHP上传文件时被烧坏了足够多的时间,我们本能地写下了“check
$FILES[…]['error']
”;)请把问题的标题改好。。