如何在 php 中上传、插入数据库和重命名文件


How do i upload, insert to database and rename files in php?

>我的项目遇到了一些问题,我正在制作一个漫画阅读器网站,我制作了多种形式的章节图片,所以这是代码

$manga_id = $_GET['manga_id'];          
    mysql_connect("localhost","root","");
    mysql_select_db("task3");
    $chapternumber = $_POST['chapternumber'];
    $chaptertitle = $_POST['chaptertitle'];
        $a=0;
        foreach ($_FILES['pictures']['name'] as $filename) 
        {
            $tmp=$_FILES['pictures']['tmp_name'][$a];
            $target = "C:''wamp''www''task''comic''images''chapter''".$_FILES['pictures']['name'][$a];
            move_uploaded_file($tmp, $target);
            rename("images/chapter/$filename","images/chapter/$manga_id-$chapternumber-$a.jpg");
            $a=$a + 1;
            mysql_query("insert into chapter(ID_Komik,No_Chapter,ch_title,Halaman,pictures) 
            values ('$manga_id','$chapternumber','$chaptertitle','$a','$manga_id-$chapternumber-$a.jpg')"); 
        }
        header("Location: main.php?page=manga&&manga_id=$manga_id");

我的语法有什么问题? 数据库中的文件已重命名,但文件没有移动到目标,我是PHP的新手,但我必须更加努力,请回答,对不起我的英语不好

in

$target

你应该使用你的PHP文件的相对路径

例如:

$target = "图像''章节''".$_FILES['图片']['名称'][$a];

祝你好运!