ADDT file upload
Hi people
I'm making a document upload site for mainly pdf files with
php and mysql and i'm using the developer toolbox file upload.
I got it all to work except one thing - international
charachters in the file names. I need to convert the signs to html
code but how do i do it? Is it htmlentities() i should use? but
where should i put it in the code?
Would appreciate some help on this one - cheers.
Better post this question to the Developer Toolbox PHP
Application Development forum:
http://www.adobeforums.com/webx/.3bc3909c/
...and if you do, I´ll provide a solution over there
:-)
Similar Messages
-
ADDT file upload server behavior / file ownership on server
When using the ADDT file upload server behavior, I found out that the files stored on my server have the ownership "www-data www-data", where other files uploaded (with Dreamweaver or a FTP client) have the ownership "[mydomain] www-data.
This means I cannot manipulate these ADDT uploaded files with a FTP client like Filezilla or in the Dreamweaver file window, because I then get an error message saying I don't have the required permission for that operation (eg delete the file).
Any clue on how to solve this problem?
Thanks in advance,
ErikYou can also check with your host if they are running suexec. If they are you can possibly use a PHP-CGI wrapper in your script to have it create files/folders with the right permissions. It's more about the ownership of the php interpreter. Surprising though as I never seen ADDT have this kind of issue. I have seen this issue several times in hand written scripts by me where I don't do a lot of pre-checking.
-
File upload java errors...HEEELPPP!
All was working fine for months, now getting java errors in my ADDT. Mostly related to file uploads, or image uploads. I found that I don't get these errors in older sites that I've worked with, but I've created a new site and started from scratch and I'm still getting them.
Here are the errors and what I'm doing:
*I go insert record form wizard (in ADDT)
*One field is a date, others are text, one is an integer, one is a file field
That works ok up to here.
*Then I choose ADDT > File upload. I get the following error immediately: "While executing canApplyserverBehavior in kb_FileUpload.htm, a javascript error occured."
*I click ok, the wizard box attempts to load and it give me the error: "While executing onLoad in kb_FileUpload.htm, the following javascript errors occured:
At line 354 of the file "Macintosh HD:Applications:Adobe Dreamweaver CS3:Configuration:Shared:DeveloperToolbox:classes:triggerUtil.js":
TypeError: hash[transactionColumn[k]].push is not a fuction.
I'm totally tearing my hair out, not to mention not hitting deadlines with this... can anyone help. I've tried removing the fileCache, rebuilding the site cache, removing and rebuilding the includes folder, removing and reinstalling ADDT. HEEEEEELLLLLPPP.Hi
Please look into this about the destination
Pathname of directory in which to upload the file. If not an
absolute path (starting a with a drive letter and a colon, or a
forward or backward slash), it is relative to the ColdFusion
temporary directory, which is returned by the GetTempDirectory
function. -
Image / file upload error cannot upload image even after setting write permissions
Hi there everyone
I am having this problem when I try to upload a file (image file) to my server
I have a dynamic for working fine , all the other fields insert the information ok then I try to add an image upload behaviour to a file field
When I try to upload the file I get this error
Error:
An error occurred while inserting the records.
File upload error: File upload error. Error creating folder..
File upload error. Internal error.
Developer Details:
tNG_multipleInsert error.
An error occurred while inserting the records. (MINS_ERROR)
File upload error: PHP_UPLOAD_FOLDER_ERROR
File Upload Error. No write permissions in "../../productimages/" folder.
(FILE_UPLOAD_ERROR)
So I login to my server and change the write permissions to 777 and then try again and get the same message
I have closed DW and tried again and still get the same message......
I think I have followed all the steps correctly..... I have done the same type of forms many time and tested them locally on WAMP testing server and all work ok......
So..... Anyone got any ideas
Any help would be great
Have a nice dayOn 5/17/07 4:26 PM, in article [email protected],
"Gü[email protected]" <> wrote:
>
> To my experience servers behave differently -- on some I really had to use
> 777, others are happy with 755.
>
> in regards to "any user" :: On most ADDT respectively MX Kollection - based
> backends I made the image & file upload feature available to user having e.g.
> the "levels" 1 & 2, but not 3 -- I wouldn´t expose something like this to all
> users
>
> Günter Schenk
> Adobe Community Expert, Dreamweaver
My backend is only for admin, so they are the only ones who can access the
upload pages. My concern is an images folder on the site being 777. Can't
anyone from the outside plant a file in that folder if they just know where
to find it using an ftp program? ? -
I have installed the File Upload sample in a Windows 2000 machine with 6i Form Server. When I start the web browser in the machine with the 6i Form Server, I can upload the file without problem. But when I start the web browser in another PC and accessing the 6i Form Server, the file seems uploaded but with 0 byte!!! Besides, the web browser in the PC hangs up.
Please advise what is the most likely cause of the problem, thanks.
SKI have several applications using the "multiple upload" behavior with clients on IE7 and flash player 9. Out 8 I only had same problem with one., even though they were created off the same base structure. The solution I found was as simple as it is mysterious.
"Is the file you have this behavior located within the same directory as the "includes" folder or within another directory? "
Let's say the directory of the includes folder is:
root/public_html/includes
and your page with the behavior is:
root/public_html/folder/multiUpload.php
For some reason and not on all sites if the file with the behavior is not in the same directory as the includes folder then the behavior you described occurs. The solution I came up with is to make a folder in the directory named "includes" and copy the "tng" into the folder on the same level as the file with the behavior.
root/public_html/folder/includes
root/public_html/folder/multiUpload.php
Hope this works for you, it took me the better part of a week to figure this out, not sure why it works, I suspect a setting within ADDT was corrupted. Like I said before most of my clients don't have this problem even though they all use the same files (as in copies).
Hope this helps
M -
Progress Bars in File Upload Behavours
Progress Bars in File Upload Behavours would be great.
I think we need to be realistic ;)
KTML4 - isn't going to happen, it was dropped, other 3rd party products are surfacing,
sadly, we'll not see that again.
Calendar was a separate Interakt application (not really a toolkit item)
like the ADDT form control date/calendar picker - so I doubt that will happen
That said - it would still get my vote for a comeback.
Ajax tool - need to specify EXACTLY what tool and how it would expand on the ADDT and how it would relate to SPRY and other Components now being made available for DWCS4 ie YUI etc
atb
Paul -
File upload custom renaming not working with {KT_ext}
Hi,
I used many times custom renaming with file upload, and used {KT_ext} for file's extension, but in first ADDT project is not working. I use this:
$uploadObj->setRenameRule("{GET.id_cd}_{track}.{KT_ext}");
Does anybody know if {KT_ext} is broken in ADDT?
Thank you,
RubenHi Günter,
{track} and {id_track} are both table fields, and setRenameRule worked right with both, but it didn't with {KT_ext}.
I've changed {track} with {id_track} in first page, and it stills fail to put extension.
But maybe is this, in first page the column for Update Transaction is like this
$upd_cds_peces->addColumn("mp3", "FILE_TYPE", "POST", "mp3");
and in the second page (where it works right) is
$upd_cds_peces->addColumn("mp3", "FILE_TYPE", "FILES", "mp3");
Althought in both cases the file is uploaded and DDBB field is filled, maybe in first case the TNG doesn't expect a file and cannot find its extension.
I'll try to change it,
thanks,
Ruben
Edit: Yes, it was this... Now it works. Thank you Günter for your help! -
I am trying to build a page to upload pdf files to my website. It is an intranet site for real estate agents. I tried making a form with a file field and then applied the Developer toolkit file upload behavior. When I try to view the page I get this error:
Microsoft VBScript compilation error '800a0401'
Expected end of statement
/BusCenter/forms/formsUpload.asp, line 49
ins__forms_.setTable ""forms""
-----------------------^
Can anyone help me get this working?
Thanks!
Ben
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../Connections/conBusCenterString.asp" -->
<!--#include file="../includes/common/KT_common.asp" -->
<!--#include file="../includes/tNG/tNG.inc.asp" -->
<%
'Make a transaction dispatcher instance
Dim tNGs: Set tNGs = new tNG_dispatcher
tNGs.Init "../"
%>
<%
' Start trigger
Dim formValidation: Set formValidation = new tNG_FormValidation
formValidation.Init
formValidation.addField "fmName", true, "text", "", "", "", "Please enter a valid form name."
formValidation.addField "fmDesc", true, "text", "", "", "", "Please enter a valid description."
formValidation.addField "fmCatA", true, "text", "", "", "", "Please enter a valid catagory."
formValidation.addField "fmCatB", true, "text", "", "", "", "Please enter a valid catagory."
formValidation.addField "fmFile", true, "", "", "", "", "Please select a file to uoload."
tNGs.prepareValidation formValidation
' End trigger
%>
<%
'start Trigger_FileUpload trigger
'remove this line if you want to edit the code by hand
Function Trigger_FileUpload (ByRef tNG)
Dim uploadObj: Set uploadObj = new tNG_FileUpload
uploadObj.Init tNG
uploadObj.setFormFieldName "fmFile"
uploadObj.setDbFieldName "fmFile"
uploadObj.setFolder "../forms/forms/"
uploadObj.setMaxSize 2500
uploadObj.setAllowedExtensions "pdf, txt"
uploadObj.setRename "auto"
Set Trigger_FileUpload = uploadObj.Execute()
End Function
'end Trigger_FileUpload trigger
%>
<%
' Make an insert transaction instance
Dim ins__forms_: Set ins__forms_ = new tNG_insert
ins__forms_.init MM_conBusCenterString_STRING
tNGs.addTransaction ins__forms_
' Register triggers
ins__forms_.registerTrigger Array("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1")
ins__forms_.registerTrigger Array("BEFORE", "Trigger_Default_FormValidation", 10, formValidation)
ins__forms_.registerTrigger Array("END", "Trigger_Default_Redirect", 99, "formsList.asp")
ins__forms_.registerTrigger Array("AFTER", "Trigger_FileUpload", 97)
' Add columns
ins__forms_.setTable ""forms""
ins__forms_.addColumn "fmName", "STRING_TYPE", "POST", "fmName", ""
ins__forms_.addColumn "fmDesc", "STRING_TYPE", "POST", "fmDesc", ""
ins__forms_.addColumn "fmCatA", "STRING_TYPE", "POST", "fmCatA", ""
ins__forms_.addColumn "fmCatB", "STRING_TYPE", "POST", "fmCatB", ""
ins__forms_.addColumn "fmFile", "FILE_TYPE", "FILES", "fmFile", ""
ins__forms_.setPrimaryKey "fmID", "NUMERIC_TYPE", "", ""
%>
<%
'Execute all the registered transactions
tNGs.executeTransactions
%>
<%
'Get the transaction recordset
Dim rs_forms_
Dim rs_forms__numRows
Set rs_forms_ = tNGs.getRecordset(""forms"")
rs_forms__numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="../includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="../includes/common/js/base.js" type="text/javascript"></script>
<script src="../includes/common/js/utility.js" type="text/javascript"></script>
<script src="../includes/skins/style.js" type="text/javascript"></script>
<% Response.Write tNGs.displayValidationRules()%>
</head>
<body>
<%
Response.Write tNGs.getErrorMsg()
%>
<form action="<%= KT_escapeAttribute(KT_getFullUri()) %>" method="post" enctype="multipart/form-data" name="fmFile" id="fmFile">
<table cellpadding="2" cellspacing="0" class="KT_tngtable">
<tr>
<td class="KT_th"><label for="fmName">Name:</label></td>
<td><input type="text" name="fmName" id="fmName" value="<%=(KT_escapeAttribute(rs_forms_.Fields.Item("fmName").Value))%>" size="32" />
<%=(tNGs.displayFieldHint("fmName"))%> <%=(tNGs.displayFieldError(""forms"", "fmName"))%> </td>
</tr>
<tr>
<td class="KT_th"><label for="fmDesc">Description:</label></td>
<td><input type="text" name="fmDesc" id="fmDesc" value="<%=(KT_escapeAttribute(rs_forms_.Fields.Item("fmDesc").Value))%>" size="32" />
<%=(tNGs.displayFieldHint("fmDesc"))%> <%=(tNGs.displayFieldError(""forms"", "fmDesc"))%> </td>
</tr>
<tr>
<td class="KT_th"><label for="fmCatA">CatA:</label></td>
<td><input type="text" name="fmCatA" id="fmCatA" value="<%=(KT_escapeAttribute(rs_forms_.Fields.Item("fmCatA").Value))%>" size="32" />
<%=(tNGs.displayFieldHint("fmCatA"))%> <%=(tNGs.displayFieldError(""forms"", "fmCatA"))%> </td>
</tr>
<tr>
<td class="KT_th"><label for="fmCatB">CatB:</label></td>
<td><input type="text" name="fmCatB" id="fmCatB" value="<%=(KT_escapeAttribute(rs_forms_.Fields.Item("fmCatB").Value))%>" size="32" />
<%=(tNGs.displayFieldHint("fmCatB"))%> <%=(tNGs.displayFieldError(""forms"", "fmCatB"))%> </td>
</tr>
<tr>
<td class="KT_th"><label for="fmFile">File:</label></td>
<td><input type="file" name="fmFile" id="fmFile" size="32" />
<%=(tNGs.displayFieldError(""forms"", "fmFile"))%> </td>
</tr>
<tr class="KT_buttons">
<td colspan="2"><input type="submit" name="KT_Insert1" id="KT_Insert1" value="Insert record" /></td>
</tr>
</table>
</form>
<p> </p>
</body>
</html>Well at first you can try the ADDT support forum and not this
one. Its more likely to have a reply there.
At second, the basic question:
Are your server folders with 777 permission? -
Multiple File Upload - Database
Hi
I have tried and I can't work it out. I have a insert record function which enters the data into the database. I have the filepath set to a file field. If I add an "Upload File" function from ADDT it uses the file field to upload the PDF and also adds the file path to the database.
How do I get the 'Multiple File Upload" to upload the files when I click "Insert Record".
'Multiple File Upload" adds an upload link which seems to be separate from the 'Insert Form"
I hope this makes sense to someone
Cheers
LaurenceHi Laurence,
'Multiple File Upload" adds an upload link which seems to be separate from the 'Insert Form"
that´s true, and that´s also the reason why multiple file or image upload triggers IMHO should rather be attached to an "update record" form -- because here´s where the respective record´s primary key has already been stored and can be used as part of the upload transaction
(e.g. to create a folder named after the primary key), what would be questionable when applied to an insert record form.
I´m personally always using single file upload with ADDT´s Insert Record forms and relocate the multi upload stuff to Update Record forms -- also as a sort of "safety measure", because one never really knows if e.g. the filesize sum of all uploaded files will or will not exceed the server´s "upload_max_filesize" value and hence might possibly break the upload procedure.
Cheers,
Günter Schenk
Adobe Community Expert, Dreamweaver -
Hi all
Way back when Razvan created a fix for me in the (then) Kollection KT_Image.class.php which solved the image upload and resize issue for .bmp files.
I just updated one site to ADDT and of course the file upload now is busted.
To cut a long story short - has anyone got around uploading .bmp files with the image upload functions?
I am using GD.
OwenDammit no - i deleted the includes folders locally and remotely like an idiot!
It was something to do with a case 6: in a switch on line 1779 (or it may have been line 179)
I've tried that but i still get the error:
Image upload error. Error resizing image: Error converting image (image resize). The file "/var/www/vhosts/slauctions.co.uk/httpdocs/auctionpics/tap_10015.jpg" is invalid. (IMG_RESIZE) -
what causes this error:
File upload error: Error uploading file. Error moving uploaded file from temporary folder. (FILE_UPLOAD_ERROR)On 5/17/07 4:26 PM, in article [email protected],
"Gü[email protected]" <> wrote:
>
> To my experience servers behave differently -- on some I really had to use
> 777, others are happy with 755.
>
> in regards to "any user" :: On most ADDT respectively MX Kollection - based
> backends I made the image & file upload feature available to user having e.g.
> the "levels" 1 & 2, but not 3 -- I wouldn´t expose something like this to all
> users
>
> Günter Schenk
> Adobe Community Expert, Dreamweaver
My backend is only for admin, so they are the only ones who can access the
upload pages. My concern is an images folder on the site being 777. Can't
anyone from the outside plant a file in that folder if they just know where
to find it using an ftp program? ? -
I'm encountering this error and not sure how to fix, I'm quite new to vCenter so please bear with me.
I'm trying out vCenter 5.1 with Update Manager 5.1 right now. No license key has been entered and I still have 50 odd days to try it out.
2 ESXi hosts are being managed by this vCenter, and they're both running ESXi 4.0
I'm looking to use Update Manager to try to upgrade the ESXi 4.0 hosts to ESXi 5.1
I downloaded the image file VMware-VIMSetup-all-5.1.0-799735.iso from VMWare website, and is looking to import it using the Update Manager so I can update the ESXi hosts, but I keep on getting the error:
File name: VMware-VIMSetup-all-5.1.0-799735.iso
Failed to transfer data
Error was: A web exception has occurred during file upload
I tried importing it by using vSphere client to connect to vCenter server both remotely and locally, with firewall disabled.
I've read http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1026602
I've disabled firewall, and there is no anti-virus program on the server. I've also restarted the machine several times, to no avail, I didn't reinstall update manager because the whole Windows and VCenter installations are clean from scratch.
I logged into the vSphere Client using Active Directory credentials, and I've made all Domain Admins (which my account is a member of) part of the administrator group on the vCenter server. I can't log in using admin@System-Domain because it tells me I don't have permissions for it, I still haven't really had the chance to figure out why that is and not sure if that makes a difference.
Also, I'm fairly certain I'm using the right image file, as I've burned some DVD's used that image file to upgrade some other ESXi hosts. Unless there's a special image file I need to download?
I'm at lost on what I can do to make it work. Please advise.
Thanks.The ISO file you mentioned is the one for vCenter Server. What you need is the "VMware-VMvisor-Installer-5.1.0-799733.x86_64.iso" (or VMware-VMvisor-Installer-201210001-838463.x86_64.iso) for the ESXi host.
André -
1. when use com.oreilly.servlet.MultipartRequest to handle the file upload, can I change the upload file name .
2. how com.oreilly.servlet.MultipartReques handle file upload? do it change to byte ?
what different? if I use the following method?
File uploadedFile = (File) mp.getFile("filename");
FileOutputStream fos = new FileOutputStream(filename);
byte[] uploadedFileBuf = new byte[(int) uploadedFile.length()];
fos.write(data);
fos.close();My questions are
1) when use oreilly package to do file upload , it looks like i line of code is enough to store the upload file in the
file direction.
MultipartRequest multi =
new MultipartRequest(request, dirName, 10*1024*1024); // 10MB
why some example still use FileOutputStream?
outs = new FileOutputStream(UPLOADDIR+fileName);
filePart.writeTo(outs);
outs.flush();
outs.close();
2) can I rename the file name when I use oreilly package? -
BI IP --- Planning function for File Upload
Hai All,
In BI IP , When I am trying to load the data (text file) by using Planning function for File Upload. I am getting an error message When I am clicking on Update .
Error Message : Inconsistent input parameter (parameter: <unknown>, value <unknown>).
In Text file I am using Tab Separation for each value
Anyone help me out.
Thanks,
BhimaHi Bhima
Try one of these; it should work:
1. If you are on SP 14 you would need to upgrade to SP 15. It would work fine
2. If not, then -
a] apply note 1070655 - Termination msg CL_RSPLFR_CONTROLLER =>GET_READ_WRITE_PROVIDS
b] Apply Correction Instruction 566059 [i.e: in Object - CL_RSPLFR_CONTROLLER GET_READ_WRITE_PROVIDS,
delete the block: l_r_alvl = cl_rspls_alvl=>factory( i_aggrlevel = p_infoprov ).
and insert block - l_r_alvl = cl_rspls_alvl=>factory( i_aggrlevel = i_infoprov ).
Goodluck
Srikanth -
FILE UPLOAD PROBLEM SHOWING THE CONTENTS IN THE SAME BROWSER WINDOW
Hi,
This is amit Joshi
I have uploaded content using input tag of type file and posted to jsp as multipart/form-data type
in that jsp i am using following code to display the content in browser but only first content is displayed How can i modify it to show all content in the file ..
<html>
<head>
<title>File Upload Display</title>
</head>
<body>
<%
//ServletOutputStream sout=response.getOutputStream();
StringBuilder strBuilder = new StringBuilder();
int count=0;
String f;
f=request.getParameter("filedb");
DBManager dbm = new DBManager();
//dbm.createTable("mms3");
//log.info("In JSP : "+ f);
//dbm.insert_data(f,"mms3");
%>
<%
if (ServletFileUpload.isMultipartContent(request)){
ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
List fileItemsList = servletFileUpload.parseRequest(request);
strBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>").append('\r').append('\n').append("<xpage version=\"1.0\">").append('\r').append('\n');
String optionalFileName = "";
FileItem fileItem = null;
Iterator it = fileItemsList.iterator();
ServletOutputStream outputStream=null;
while (it.hasNext()){
FileItem fileItemTemp = (FileItem)it.next();
if (fileItemTemp.isFormField()){
%>
<b>Name-value Pair Info:</b>
Field name: <%= fileItemTemp.getFieldName() %>
Field value: <%= fileItemTemp.getString() %>
<%
if (fileItemTemp.getFieldName().equals("filename"))
optionalFileName = fileItemTemp.getString();
else
fileItem = fileItemTemp;
if (fileItem!=null){
String fileName = fileItem.getName();
%>
<b>Uploaded File Info:</b>
Content type: <%= fileItem.getContentType() %>
Field name: <%= fileItem.getFieldName() %>
File name: <%= fileName %>
<%
if(fileItem.getContentType().equals("image/jpeg")) { %>
File : <p><%
//response.setContentType("image/gif");
byte[] bArray=fileItem.get();
response.setContentType("image/jpeg");
outputStream=null;
outputStream= response.getOutputStream();
outputStream.write(bArray);
outputStream.flush();
outputStream.close();
else if(fileItem.getContentType().equals("text/plain"))
%> File : <%= fileItem.getString() %>
<%
byte[] bArray=fileItem.get();
response.setContentType("text/plain");
outputStream = response.getOutputStream();
out.println();
outputStream.write(bArray);
outputStream.flush();
outputStream.close();
%> </p> <%
%>
</body>
</html>
Edited by: Amit_Joshi on Nov 13, 2007 10:58 PMWell Well Well..
That would not work...
What you have to do is save the uploaded file content on to a location and then pass the fileName as a request parameter to a deidicated which displays the contents of that file.
Just as an example
<html>
<head>
<title>File Upload Display</title>
</head>
<body>
<%
//ServletOutputStream sout=response.getOutputStream();
StringBuilder strBuilder = new StringBuilder();
int count=0;
String f;
f=request.getParameter("filedb");
DBManager dbm = new DBManager();
//dbm.createTable("mms3");
//log.info("In JSP : "+ f);
//dbm.insert_data(f,"mms3");
%>
<%
if (ServletFileUpload.isMultipartContent(request)){
ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
List fileItemsList = servletFileUpload.parseRequest(request);
strBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>").append('\r').append('\n').append("<xpage version=\"1.0\">").append('\r').append('\n');
String optionalFileName = "";
FileItem fileItem = null;
Iterator it = fileItemsList.iterator();
ServletOutputStream outputStream=null;
while (it.hasNext()){
FileItem fileItemTemp = (FileItem)it.next();
%>
Name-value Pair Info:
Field name: <%= fileItemTemp.getFieldName() %><br/>
Field value: <%= fileItemTemp.getString() %><br/>
<%
if (fileItemTemp.getFieldName().equals("filename"))
optionalFileName = fileItemTemp.getString();
if(!fileTempItem.isFormFiled()){
String fileName = fileItem.getName();
fileItem.write(optionalFileName);
%>
Uploaded File Info:
Content type: <%= fileItem.getContentType() %><br/>
Field name: <%= fileItem.getFieldName() %><br/>
File name: <%= fileName %><br/>
<%
if(fileItem.getContentType().equals("image/jpeg") || fileItem.getContentType().equals("image/pjeg")) {
%>
<img src="FileServlet?fileName=<%=optionalFileName%>"
<%
%>
</body>
</html>a sample code snippet for FileServlet.
String fileName = request.getParameter(fileName);
File file = new File(fileName);
if(!file.exists())
return;
// If JSP
String mimeType = application.getMimeType("fileName");
If you are using servlet
String mimeType = this.getServletContext().getMimeType(fileName);
response.setContentType(mimeType);
response.setHeader("Content-Disposition","inline;filename=\\"+fileName+"\\");
BufferedOutputStream out1 = null;
InputStream in = null;
if(mimeType == null)
mimeType = "application/octet-stream";
try{
in = new FileInputStream(f);
response.setContentLength(in.available());
BufferedOutputStream out1 = new BufferedOutputStream(response.getOutputStream(),1024);
int size = 0;
byte[] b = new byte[1024];
while ((size = in.read(b, 0, 1024)) > 0)
out1.write(b, 0, size);
}catch(Exception exp){
}finally{
if(out1 != null){
try{
out1.flush();
out1.close();
}catch(Exception e){}
if(in != null){
try{in.close();}catch(Exception e){}
} Hope that might answer your question :)
However,this is not the recommended way of doing this make use of MVC pattern.Would be a better approach.
you might think of googling on this and can findout what is the best practise followed for problems of this sort
REGARDS,
RaHuL
Maybe you are looking for
-
Adobe Acrobat XI Pro Trial Download
Dear Sir/Madam:- Using Windows 7, I7 Processor, 64 bit OS, 16GB memory. Had Adobe Acrobat X, OK. Uninstalled Adobe X, using the normal Windows uninstall procedure. Rebooted. Downloaded and installed the trial Adobe Acrobat XI. Double click Adobe Acro
-
Purging archivelogs on Primary and Standby
Hi all, 11.2.0.1 Aix 6.1 I am monitoring space usage in our FRA for both DG primary and standby. I want to purge all archivelogs once they have been applied to standby. What is the use of it anyway? I checked google and I found this procedure, kindl
-
Hi, my laptop HP G62 freezes suddenly during usage. Neither detects mouse or keyboard. The display remains as it is. I have to remove the battery or long press the power button to get it an improper shut down and start once again. It's freezing at in
-
Can not add virtual interface on VirtualBox (SOLVED)
Hi guys , as tittle says , While trying to add an "host only" netwkork interface I get the following message: VBoxNetAdpCtl: Error while adding new interface: failed to open /dev/vboxnetctl: No such file or directory Im not sure if it is a kernel/mod
-
I have an iPad and need Cloud help! Please
I have an iPhone and an iPad. I have purchased extra space on iCloud and (I BELIEVE) have my settings so that BOTH should back up to my iCloud. The problem that I'm having is that some items (Notes for example, contacts and email) are on my phone and