我正在创建一个使用applet创建的项目。在我的项目中,我使用applet为图像创建效果。最初,我做了一个项目,只有一个图像存储在相同的位置作为项目的文件。
我使用下面的代码调用applet<applet code=ImageFilterDemo width=1024 height=480>
<param name=img value="<?php echo $file; ?>">
然后传入图像的名称,在本例中是1.jpg
我尝试创建一个表单来帮助选择和上传文件:
<form action="filter.html" method="post" enctype="multipart/form-data">
Select IMAGE : <input type="file" name="image" /> <input type="submit" value="Upload" />
</form>
然后我尝试使用php代码
获取图像的文件名 <?php $file= $_FILES['image']['tmp_name']; ?>
我不是php专家。我试着看看我犯了什么错误,但仍然不知道是什么错误。
注意:我希望applet在选择文件并单击上传时加载图像。
//在PHP文件中加载一个applet
<applet code="appletname.class" height=someint width=someint>
</applet>
and inside applet init() method
add this line
String str_loc=getParameter("image_file_location_set_via_php_inside_param_tag");**
Now using HttpUrlConnection use this location to fetch the image if its over the web
else use
Normal file handling
欢呼
W3 schools有一个关于处理文件上传的很好的教程:http://www.w3schools.com/php/php_file_upload.asp
您应该将上传的文件保存到一个永久的位置,并将该位置用于您的applet。
此外,文件通常被上传到一个临时的,非web访问的目录,所以当你的applet通过文件名请求文件时,它无法被找到,因为它在错误的目录中。