0

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?

2
Contributors
12
Replies
13
Views
6 Years
Discussion Span
Last Post by 54uydf
0

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?

0

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);		
}
0

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.

Edited by NormR1: n/a

0

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.	
}
0

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?

Edited by NormR1: n/a

0

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.

0

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

0

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.

0

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.

0

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)..

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.