as the title implies I'm trying to upload a file to a local server and for that purpose I'm using a JSP and uploadify (flash-based jquery uploader). I have already succeeded on uploading a file using glassfish server 3.1 and this as my HTML code:
</head>
<body>
<table>
<tr>
<td>
<input id="file_upload" name="file_upload" type="file" />
<script type="text/javascript">
$('#file_upload').uploadify({
'uploader' : 'uploadify/uploadify.swf',
'script' : 'UploadFile/uploadFile.jsp',
'cancelImg' : 'uploadify/cancel.png',
'multi' : true,
'auto' : false,
'onComplete' : function(fileObj)
{
alert (fileObj.filePath); //The path on the server to the uploaded file
}
});
</script>
</td>
<td>
<a href="javascript:$('#file_upload').uploadifyUpload($('.uploadifyQueueItem').last().attr('id').replace('file_upload',''));">Upload Last File</a>
</td>
</tr>
</table>
</body>
And this as my server-side script:
<%@ page import="java.io.*" %>
<%
String contentType = request.getContentType();
if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) {
DataInputStream in = new DataInputStream(request.getInputStream());
int formDataLength = request.getContentLength();
byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
while (totalBytesRead < formDataLength) {
byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
totalBytesRead += byteRead;
}
String file = new String(dataBytes);
String saveFile = file.substring(file.indexOf("filename=\"") + 10);
saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1, saveFile.indexOf("\""));
int lastIndex = contentType.lastIndexOf("=");
String boundary = contentType.substring(lastIndex + 1,contentType.length());
int pos;
pos = file.indexOf("filename=\"");
pos = file.indexOf("\n", pos) + 1;
pos = file.indexOf("\n", pos) + 1;
pos = file.indexOf("\n", pos) + 1;
int boundaryLocation = file.indexOf(boundary, pos) - 4;
int startPos = ((file.substring(0, pos)).getBytes()).length;
int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
FileOutputStream fileOut = new FileOutputStream(saveFile);
fileOut.write(dataBytes, startPos, (endPos - startPos));
fileOut.flush();
fileOut.close();
%>
<table>
<tr>
<td>
<b>File uploaded:</b>
<% out.println(saveFile);%>
</td>
</tr>
</table>
<%} else {
out.println(contentType.indexOf("multipart/form-data"));
out.println(request.getContentType());
%>
<br/> error <% } %>
So my question is, is it possible to change the default folder to upload things to? e.g: My default folder right now is C:\Users\USERNAME.netbeans\7.0\config\GF3\domain1 is it possible to change it to C:\Users\USERNAME\Desktop ?
If I was not clear enough with the question feel free to say it, any help is greatly appreciated, thanks.