如何使用PHP获取图像位置并将其发送到applet?

时间:2013-04-08 12:31:19

标签: java php html image applet

我正在创建一个使用Applet创建的项目。在我的项目中,我使用applet为图像创建效果。最初我只使用与项目文件相同的位置存储了1个图像来完成项目。

我使用以下代码调用我的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在选择文件并单击上载时加载图像。

2 个答案:

答案 0 :(得分:0)

//像这样在你的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

欢呼声

答案 1 :(得分:-2)

W3学校提供了一个处理文件上传的好教程:http://www.w3schools.com/php/php_file_upload.asp

您应该将上传的文件保存到永久位置,并将该位置用于您的小程序。

此外,文件通常上传到临时的,不可通过Web访问的目录,因此当您的applet按名称请求文件时,无法找到它,因为它位于错误的目录中。