Hi, I'm seriously guessing here, but since I've seen that some php websites contain java stuff, like a java chatroom, I wonder if I can find a better solution adding some java to my php code.
I'm looking for a way to browse and select a folder, or allow the user to select multiple files in a folder (using the ctrl/shift key) so I can upload all the files in it to a server. what I'm trying to do is to avoid making the user browes and select each file separately, as most uploading files solution do (still haven't found a code that doesn't)
is there such file browser in java, and if yes, can I add it to my website and mix it with my php?

I'm looking for a way to browse and select a folder,

An applet with permissions could do that if you want to do it from a browser.
What code would the applet talk to on the server that would be able receive a folder of files?

php code
something like this-

if ($_FILES['myfile']['name']!='') {
	$target = 'uploadedFiles/';    
	$target = $target . basename($_FILES['myfile']['name']);
	move_uploaded_file($_FILES['myfile']['tmp_name'], $target);		
}

Sorry, I don't know PHP. Can you comment the statements in your PHP code describing what it is doing?

How would an applet or application running on a user's PC communicate with your PHP code?
It would need to send the folder name and then the filenames and the contents of each file.

yeah I have no idea..
php get's all the file info from the form (html element)
so without it I don't know if this code is any good..maybe I can use a java code for it?
java applet that allows the user to chose files, and then click "ok" and java code will save them to a folder on a server, and then the rest is up to php..

if ($_FILES['myfile']['name']!='') { //$_FILE is a var that hold file's info, file id is "myfile"
	$target = 'uploadedFiles/';  //the folder to which the file will be uploaded to  
	$target = $target . basename($_FILES['myfile']['name']); //adding the file name to the foler to create full path
	move_uploaded_file($_FILES['myfile']['tmp_name'], $target);	 //moving the file that has been saved in a temp location to the targeted folder.	
}

Does your PHP code have the folder name hardcoded vs getting that info from the program uploading the files?

I've forgotten what info a browser sends to the server when it is uploading a file.
The application would probably use similar info for each file. Would you also want it to send the name of the folder so the files would be in a same named folder on the server?

didn't quite understand you..
the folder I want the files to be uploaded into on the server is hardcoded yes, I don't want anyone to choose it.
the folder from which the user will pick his files for upload is on his local computer and can be any folder.

Would all the files uploaded from any and all users go into the same folder on the server? There would be possible naming conflicts.

yeah they would, but it's a specific prosses that goes something like this-
uploading specific files at once, php is processing them for data and deletes them from the folder. so no conflict should happen..plus only 1 user is going to do this, so no chance of few people uploading the same files at the same time.

Ok, then there wouldn't be a problem.

Then its a question of writing the java code to mimic what a browser does when it uploads more than one file at a time.

isn't there any code online that does that? it seems to me like the most natural thing to allow a user to choose few files at once but I see there are not many codes that are available online..actually I found only 1..and I'm fighting with it for 5 hours already (not java)..

I'm sure there is code somewhere that does some of what you want to do. I've never needed it so I have not looked.

I feel like I'm looking in all the wrong places lol

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.