my dog learned polymorphism*
The moose likes Struts and the fly likes struts2: how to edit uploaded files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts2: how to edit uploaded files" Watch "struts2: how to edit uploaded files" New topic
Author

struts2: how to edit uploaded files

luke yu
Greenhorn

Joined: Oct 20, 2008
Posts: 8
I have succeed to upload a few files using s:file tag, but how can i edit this page ? when i edit, s:file display nothing ,so if i submit ,the file field can just upload null. Do i need to choose files again even I don't want to change the file field ? thanks
[ October 20, 2008: Message edited by: yuxh yuxh ]
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684

Hi..

Can you please first make your question clear.

because if you want to edit your uploaded file then it is not edit.

The only way to edit is open file write it and again upload it.

Image file not edit because it's binary format.

Thanks,
Nishan Patel.


Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
luke yu
Greenhorn

Joined: Oct 20, 2008
Posts: 8
sorry for my poor English, you just misunderstood "edit". In my a.jsp :

it's fine to upload and submit this page(I store the files in a dir,and put their names in database). Then I want to edit this page, I just want to edit the "title1" field but the "photoAddress" field is blank now, how can I submit without affecting the "photoAddress" that has been stored.By the way ,i use array to deal with this two file .
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684

Hi..

First of all if your tag like <s:file name ="photoAddress" />
same for both file tag.
Yes that's true if you use array for file then you have to specify index for edit.Here when you edit for file name photoAddress is same that's why it is blank each time of edit.


Thanks,
Nishan Patel.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
As a security measure, most browsers including Firefox, IE, and Safari all do not allow a server-side value to be defaulted in an <input type=file> tag. It is therefore not possible to set a default value using the s:file tag as it is eventually rendered as an <input type=file> tag.

Think about it. If this were allowed, it would be possible for a malicious site to default the value of the file to the location of your Outlook file containing all your addresses and confidential information and upload it using JavaScript before you were even aware of what was happening.

This link Explains it.
[ October 21, 2008: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
yuxh yuxh,

Please check your private messages for a message regarding an important administrative matter. You can do so by clicking My Private Messages in the upper right corner of the page.
luke yu
Greenhorn

Joined: Oct 20, 2008
Posts: 8
hi,Nishan
thank you for your reply ,but I think there is something wrong with "blank" and Merrill had explained it. finally ,i use onclick and js to judge whether the file has been changed(of course,it's not perfect :)
thanks..by the way ,it's difficult to work out a name
[ October 21, 2008: Message edited by: yuxh yuxh ]
 
 
subject: struts2: how to edit uploaded files
 
Similar Threads
Struts2 File Upload (Submit button)
Upload multiple files in jsp
Downlaod in Strut2
Struts2 multiple file upload using single file TAG
Struts multiple file upload array index problem