|
|
|
|
![]() ![]() |
Sep 28 2004, 01:00 PM
Post
#1
|
|
|
Member [ Level 2 ] Group: Members Posts: 68 Joined: 11-September 04 From: Hangzhou, China Member No.: 488 |
With Eric's help, I could deal with the upload operation with one image file now.
However, I still want to upload a set of local files, maybe the gif files in one directory, is there anyone know how to deal with php and html? Is it possible for me to upload all the image files in one directory which was only given by its path name? |
|
|
|
Sep 28 2004, 01:10 PM
Post
#2
|
|
|
Member [ Level 2 ] Group: [HOSTED] Posts: 52 Joined: 5-September 04 Member No.: 256 |
<form action=$_SERVER[PHP_SELF] method="POST" enctype="multipart/form-data">
<input type="file" name="file"> </form> <? if (strrchr ($_FILES["file"], ".") != ".gif" || strrchr ($_FIELS["file"], ".") != ".jpeg" || strrchr ($_FIELS["file"], ".") != ".png") { echo "not image!!"; } else { $time = time(); // for file name. . . copy ($_FILES["tmp_name"], "folder/".$time.$_FILES["name"]); mysql_query ("insert into database (image) values ('$time$_FILES[name]'); //I use time for file name, no same file name will be the same folder. . . } ?> |
|
|
|
Sep 28 2004, 02:34 PM
Post
#3
|
|
|
Premium Member Group: [HOSTED] Posts: 336 Joined: 22-September 04 Member No.: 798 |
are you sure this works? i don't think you can select a directory as the file to be uploaded in your form.
|
|
|
|
Sep 28 2004, 02:45 PM
Post
#4
|
|
|
Member [ Level 2 ] Group: [HOSTED] Posts: 52 Joined: 5-September 04 Member No.: 256 |
not sure, I typed the code with no checking.
but you can take a look of my photo album page. http://koolkilz.webhostingcafe.com/gallery.php I just the scripts that I've typed. very simple and ugly. . . |
|
|
|
Sep 29 2004, 03:43 AM
Post
#5
|
|
|
Member [ Level 2 ] Group: Members Posts: 68 Joined: 11-September 04 From: Hangzhou, China Member No.: 488 |
Thanks kilz, I tried your form script:
<html> <body> <form action="setload.php" method="POST" enctype="multipart/form-data"> <input type="file" name="file"> </form> </body> </html> and I copy your php script to a file named setload.php. However it couldn't solve my problem. There is only one button which could use to choose one file. I wonder if I could choose one directory. Besides, could the function copy in php copy the file from client side to server side? Otherwise, there should be file transfer, but how to do it? |
|
|
|
Sep 29 2004, 10:37 AM
Post
#6
|
|
|
Premium Member Group: [HOSTED] Posts: 336 Joined: 22-September 04 Member No.: 798 |
when input type is file you cannot choose a dir
the only thing you can do is make several input fields, for example 5 and then only one 'upload' button that will send 5 files simultanuous. another option is to use www.net2ftp.com and zip your files and upload them all at once |
|
|
|
Sep 30 2004, 12:12 AM
Post
#7
|
|
|
Member [ Level 2 ] Group: Members Posts: 68 Joined: 11-September 04 From: Hangzhou, China Member No.: 488 |
I see. There are many sites provide multi-files loading with multi input fields. However, I did find several sites can upload all the images in one directory to the server as we chose a certain directory. So there should be some solution to upload a directory.
To zip a set of files is ok to transfer the data to the server, but we should unzip the files at the server side then, it makes some trouble. I'm thinking there should be some API/ActiveX alike objects in windows/linux could support the upload of a directory. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 11th October 2008 - 12:03 PM |