Page 1 of 1

uploading a file

Posted: Mon Nov 07, 2011 3:14 am
by 54uydf
Hi, really need some extra brains to help me with this one!
I have a form with only 1 text box (input type=text)
in this textbox I enter a local path on my computer to a specific folder. in this folder I have few files, each has a set name that I know in advance.
what I want to do is to be able to upload all those files in my local folder to the server, without making the user click browes and pick them 1 by 1.
I searched and searched but I see it's not as simple as I thought cuz I can't just set the value of the input file..
since my page has a form eitherway I thought of maybe doing something sneaky and hiding the input files and some how passing them the path of each file (the folder path will be taken from the not hidden textbox) and the file name is known to me so I can add those 2 somehow..
I can't find a way to do that, so I wonder if any of you have an idea? maybe it's possible to set the file path after the form is submited? basicly I think it's possible to give the name of the file, but I also need the temp name of the file ($_FILES['docfile1']['tmp_name']), and this I don't know how to set..

this is my code for uploading a file with <input type=file>

Code: Select all

if ($_FILES['docfile1']['name']!='') {	
   $target = 'import/';    	
   $target = $target . basename($_FILES['docfile1']['name']);	
   if ($target =="import/myfile.xlsx"){		
          if (file_exists($target))			
              unlink($target);		
          if (move_uploaded_file($_FILES['docfile1']['tmp_name'], $target))   {	
               echo 'success';		
          }else{			
               echo 'fail';  				
          }	
     }else{	         
         echo 'fail'; 	
    }
}
desperately need help!

Re: uploading a file

Posted: Mon Nov 07, 2011 4:51 am
by 54uydf
ok I see not much is happening..
maybe anybody knows of a solution I can use that is not in PHP?
is it really impossible to upload multiple files without selecting each one of them 1 by 1??

Re: uploading a file

Posted: Mon Nov 07, 2011 6:14 am
by mikeashfield

Re: uploading a file

Posted: Mon Nov 07, 2011 9:01 am
by 54uydf
I saw an array and my eyes went like this 8O lol but I see it still requiers the user to chose each file separately :?
not what I'm looking for..

Re: uploading a file

Posted: Mon Nov 07, 2011 9:16 am
by Celauran
54uydf wrote:is it really impossible to upload multiple files without selecting each one of them 1 by 1??
As far as I can tell, yes. HTML 5 supports the multiple attribute, which allows you to select multiple files (except in IE, of course) but only one seems to get uploaded.

Re: uploading a file

Posted: Mon Nov 07, 2011 9:36 am
by 54uydf
lol IE is kinda important haha, but wow if there was like a simple setting I could change on this standard input file I think I might have saved myself 2 months of headache of trying to find ather solutions..
can't believe such basic thing isn't available with a simple tag.. :crazy: