Multiple file upload in php

前端 未结 14 1633
轮回少年
轮回少年 2020-11-21 11:32

I want to upload multiple files and store them in a folder and get the path and store it in the database... Any good example you looked for doing multiple file upload...

14条回答
  •  执念已碎
    2020-11-21 12:27

    Nice link on:

    PHP Single File Uploading with vary basic explanation.

    PHP file uploading with the Validation

    PHP Multiple Files Upload With Validation Click here to download source code

    PHP/jQuery Multiple Files Upload With The ProgressBar And Validation (Click here to download source code)

    How To Upload Files In PHP And Store In MySql Database (Click here to download source code)

    extract($_POST);
        $error=array();
        $extension=array("jpeg","jpg","png","gif");
        foreach($_FILES["files"]["tmp_name"] as $key=>$tmp_name)
                {
                    $file_name=$_FILES["files"]["name"][$key];
                    $file_tmp=$_FILES["files"]["tmp_name"][$key];
                    $ext=pathinfo($file_name,PATHINFO_EXTENSION);
                    if(in_array($ext,$extension))
                    {
                        if(!file_exists("photo_gallery/".$txtGalleryName."/".$file_name))
                        {
                            move_uploaded_file($file_tmp=$_FILES["files"]["tmp_name"][$key],"photo_gallery/".$txtGalleryName."/".$file_name);
                        }
                        else
                        {
                            $filename=basename($file_name,$ext);
                            $newFileName=$filename.time().".".$ext;
                            move_uploaded_file($file_tmp=$_FILES["files"]["tmp_name"][$key],"photo_gallery/".$txtGalleryName."/".$newFileName);
                        }
                    }
                    else
                    {
                        array_push($error,"$file_name, ");
                    }
                }
    

    and you must check your HTML code

    Select Photo (one or multiple):
    Note: Supported image format: .jpeg, .jpg, .png, .gif

    Nice link on:

    PHP Single File Uploading with vary basic explanation.

    PHP file uploading with the Validation

    PHP Multiple Files Upload With Validation Click here to download source code

    PHP/jQuery Multiple Files Upload With The ProgressBar And Validation (Click here to download source code)

    How To Upload Files In PHP And Store In MySql Database (Click here to download source code)

提交回复
热议问题