• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding JSPSmartUpload!!

honey singh
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I'm working on file updation process and using this JSP SmartUpload technique.
I've certain queries to ask if any body can solve my problem..The queries are as follows:-
1)this is the query if you had studied its source code. Whn it parses the data it it uses the function calles "upload()". the source code for that part is
int totalRead = 0;
int readBytes = 0;
long totalFileSize = 0L;
boolean found = false;
String dataHeader = new String();
String fieldName = new String();
String fileName = new String();
String fileExt = new String();
String filePathName = new String();
String contentType = new String();
String contentDisp = new String();
String typeMIME = new String();
String subTypeMIME = new String();
boolean isFile = false;
m_totalBytes = m_request.getContentLength();
m_binArray = new byte[m_totalBytes];
for(; totalRead < m_totalBytes; totalRead += readBytes)
readBytes = m_request.getInputStream().read(m_binArray, totalRead, m_totalBytes - totalRead);
catch(Exception e)
throw new SmartUploadException("Unable to upload.");
for(; !found && m_currentIndex < m_totalBytes; m_currentIndex++)
if(m_binArray[m_currentIndex] == 13)
found = true;
// ****(problem is here) m_boundary = m_boundary + (char)m_binArray[m_currentIndex]; **********************************************
if(m_currentIndex == 1)
if(m_currentIndex >= m_totalBytes)
dataHeader = getDataHeader();
m_currentIndex = m_currentIndex + 2;
isFile = dataHeader.indexOf("filename") > 0;
fieldName = getDataFieldValue(dataHeader, "name");
Now I want to know that to determine the boundary of the raw data it has used the code
if(m_binArray[m_currentIndex] == 13)
found = true;
// ****(problem is here) m_boundary = m_boundary + (char)m_binArray[m_currentIndex]; **********************************************
now what is the significance of the digit 13 here..this is the first query.
2) We can use it to upload the files to webserver also and we can upload it to the database server also..but now the problem is that it creates a table with the fields ID,filename and file data(BLOB)... now when we store the data in the database, then according to JSPSmartUpload it uploads only one file and if we upload other files, then the previous files get overwritten..cuz it doesn't increment the ID value and just overwrites each time file id uploaded corresponding to ID#1 only.. so what is the solution to this..
3) and the last query is that while downloading, everytime we r setting the content-type as "application/x-msdownload".. so what is the use of storing the content-types of the files, if we are not setting the content-type of the file which we had stored for that file..
I think this is too demanding...but I think u'll brave this..
Plz reply soon!
thanx very much..
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic