0

upload image problem

asked 2006-03-13 01:30:43 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3625371

By: nobody

hi, i am trying to upload a image to a tomcat server. however i can't copy the image to the dirctry that i want. can anyone help me with this.

there is my code

-----------------------------------
<window title="iframe demo" border="normal">
<iframe id="iframe" width="95%"/>
<separator bar="true"/>
<button label="Upload" onClick ="run()"/> <zscript>{ import java.awt.*; import java.awt.event.*; import java.awt.image.*; import javax.swing.*; import java.io.*; import java.net.*; import javax.imageio.*;

void run(){
Object media = Fileupload.get();
if (media != null){
File file= new File(newimage.jpg);
ImageIO.write(media,"jpg",file);
iframe.setContent(media);
}else{
Messagebox.show("Error is pressed", "Error", Messagebox.OK, Messagebox.ERROR); } } } </zscript> </window>
---------------------------------------
error is class or vriable not found

delete flag offensive retag edit

17 Replies

Sort by ยป oldest newest

answered 2006-03-13 05:16:15 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3625514

By: henrichen

Object media = Fileupload.get();

The media is a "com.potix.util.media.Media"; not a "java.awt.image.RenderedImage"
used in ImageIO.write().

Please check the JavaAPI of zul about Fileupload class and JavaAPI of pxcommon about Media for details.
http://zk1.sourceforge.net/javadoc/index.html

Also you can check the Fileupload demo source code.

/henri


link publish delete flag offensive edit

answered 2006-03-13 05:19:55 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3625518

By: henrichen

BTW, it would be more convenient if you can copy the real error stack trace.
Thanks.

/henri


link publish delete flag offensive edit

answered 2006-03-13 09:58:01 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3625799

By: nobody

hi thank you for ur reply, however i still got problem with it. I have checked java API, there is no write method under the com.potix.util.media.Media what i wanna is a client can loging to the page, and upload image to the server,( the server database is mysql) where i only wanna stort the location for the image, not the image(coverted into string) is there any method i can write the image to the dirctory that on the server?

link publish delete flag offensive edit

answered 2006-03-13 12:22:38 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3626094

By: henrichen

ZK is as thin as a presentation layer. Therefore, you have to handle the storage with java's io classes or database related classes. Since all code is running in server side, it is very easy to do whatever you want to do. (Think as if you are writing a desktop program)

What the Fileupload.get() (the uploaded image file) is a com.potix.image.AImage object (and a Media object).

AImage.getName() would give the filename while
AImage.getByteData() would give the raw data of the image (the file contents) as a byte[].

Then you use java.io.FileOutputStream to write the image raw data(the byte array) to whichever directory you like.

/henri


link publish delete flag offensive edit

answered 2006-03-13 12:27:50 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3626154

By: nobody

that cool! i think i got it work, however i just look through the java api, there is a file copy method seems can do the same job and much easier. i wonder is that will be the same? i can simply copy the image over to the directory that i want. is their any tutorial for the file copy??? i don't really know how to reference the object to the inputstream.




link publish delete flag offensive edit

answered 2006-05-29 14:11:28 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3754923

By: nobody

Hi,

I have an application with an image,is it possible to change this image dynamically with for example a button browse?


thanks,

link publish delete flag offensive edit

answered 2006-05-29 14:40:33 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3754952

By: henrichen

image.setSrc(imageurl);

link publish delete flag offensive edit

answered 2006-05-29 18:16:58 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3755257

By: nobody

I don't understand how I can do this...

I do like this but it don't work:

<button label="test" onClick="image.setSrc(images/Entete_DessinAnaxagora.gif);"
/>

How Can I chose the position of my new image?

thanks,

link publish delete flag offensive edit

answered 2006-05-30 05:34:32 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3755753

By: henrichen

<zk>
<image id="image"/>
<button label="test" onClick="image.setSrc(images/Entete_DessinAnaxagora.gif);"
/>
</zk>

link publish delete flag offensive edit

answered 2006-05-30 07:26:38 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3755838

By: nobody

I have an error mesage when I click on the button.

My message is:

Sourced file: inline evaluation of :
''image.setSrc(image/Entete_DessinAnaxagor.gif);": Class or variable not found:
Entete_DessinAnaxagora.gif at line 1.

I don't know why it don't work


thanks


link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2006-03-13 01:30:43 +0800

Seen: 391 times

Last updated: Jun 06 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More