简体   繁体   中英

Upload multiple files using php to different folders

I want to make a php upload script that takes two files through form

Form

image of form - http://i.stack.imgur.com/Q1Ivc.png

and then upload these two files in different folders like upload file1 to folder1 and file2 to folder2.

Can any body help ?

Your lack of effort disturbs me.

Check out this you'll then be able to move your file wherever you like (providing you have the correct permissions

Create a form with two file fields. Get the fields in PHP and then save the files.

Take a look at:

http://php.net/manual/en/features.file-upload.php

Try this

<form action="multiple_upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1">

    <input name="ufile[]" type="file" id="ufile[]" size="50" />
     <input name="ufile[]" type="file" id="ufile[]" size="50" />

Php Code

$path1= "upload/".$HTTP_POST_FILES['ufile']['name'][0];
$path2= "sample/".$HTTP_POST_FILES['ufile']['name'][1];


//copy file to where you want to store file
copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1);
copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM