N
Nishi Bhonsle
Hi:
The images uploaded in a directory on a web server from a client browser, end up garbled. i.e. if the image is uploaded via the UI to some dir say C:\images, after the upload, if i view the image in the destination directory, it looks garbled.
I verified that the initial image in the source location was not garbled.
I checked the file size and the permissions on the image at the destination, and it seems to be the same as the one in the source location.
I also noticed that the garbling does not happen for gif images of size 1K or 2K or 3K but for .jpg images of size > 10 K etc
(I have not found bigger .gif files to test this.)
A part of the java code that handles upload creates an object of class MultipartFormHandler (which parses an incoming file upload post).
This class parses the incoming post and returns MultipartStreamItems for each form item.
If setCharacterEncoding() is called (with anything other than null), then strings returned from this class will be character-set decoded. Otherwise, strings returned from this class are not character-set decoded. In this way, MultipartFormHandler precisely matches the behavior of ServletRequest.
MultipartFormHandler handler = new MultipartFormHandler(request);
handler.setCharacterEncoding("UTF-8");
if (imageFile != null)
{
FileReader reader = new FileReader(file);
FileWriter writer = new FileWriter(imageFile);
int c;
while ((c=reader.read()) >= 0)
{
writer.write(c);
}
reader.close();
writer.close();
}
What can cause the garble?
Thanks, Nishi.
The images uploaded in a directory on a web server from a client browser, end up garbled. i.e. if the image is uploaded via the UI to some dir say C:\images, after the upload, if i view the image in the destination directory, it looks garbled.
I verified that the initial image in the source location was not garbled.
I checked the file size and the permissions on the image at the destination, and it seems to be the same as the one in the source location.
I also noticed that the garbling does not happen for gif images of size 1K or 2K or 3K but for .jpg images of size > 10 K etc
(I have not found bigger .gif files to test this.)
A part of the java code that handles upload creates an object of class MultipartFormHandler (which parses an incoming file upload post).
This class parses the incoming post and returns MultipartStreamItems for each form item.
If setCharacterEncoding() is called (with anything other than null), then strings returned from this class will be character-set decoded. Otherwise, strings returned from this class are not character-set decoded. In this way, MultipartFormHandler precisely matches the behavior of ServletRequest.
MultipartFormHandler handler = new MultipartFormHandler(request);
handler.setCharacterEncoding("UTF-8");
if (imageFile != null)
{
FileReader reader = new FileReader(file);
FileWriter writer = new FileWriter(imageFile);
int c;
while ((c=reader.read()) >= 0)
{
writer.write(c);
}
reader.close();
writer.close();
}
What can cause the garble?
Thanks, Nishi.