Imageshack API几乎正常工作

时间:2012-02-28 10:43:43

标签: php redirect asp-classic imageshack

这个教程http://www.blocsoft.com/blog/imageshack.asp显示了上传到ima​​geshack和获取图像网址的好方法,尽管它用于ASP而我需要它在PHP中。

任何想法是否以及如何做到这一点?

谢谢你。

1 个答案:

答案 0 :(得分:1)

我刚刚将asp改写为php,没有任何线索,如果它没有测试它,但如果asp确实有效,那么php也应该。

的index.php

<html>
  <head>
    <title>AJAX image upload</title>
  </head>
  <body>
    <form action="http://imageshack.us/redirect_api.php" target="AXframe" method="post" enctype="multipart/form-data">
      <input type="file" name="media"/>
      <input type="hidden" name="key" value="YOUR_DEVELOPER_KEY">
      <input type="hidden" name="error_url" value="http://example.com/error.php">
      <input type="hidden" name="success_url" value="http://example.com/success.php?one=%y&two=%u&three=%s&four=%b&five=%i">
      <input type="submit"/>
    </form>
    <iframe style="visibility:hidden" id="AXframe" name="AXframe"></iframe>
    <div id="link"></div>
    <div id="yfrog"></div>
    <div id="image"></div>
  </body>
</html>

success.php

<?php
  $str1 = $_GET["one"];
  $str2 = $_GET["two"];
  $str3 = $_GET["three"];
  $str4 = $_GET["four"];
  $str5 = $_GET["five"];
?>

<script type="text/javascript">
  parent.document.getElementById('yfrog').innerHTML =  '<?php echo($str1); ?>';
  parent.document.getElementById('link').innerHTML = '<?php echo($str2); ?>';
  parent.document.getElementById('image').innerHTML = '<img src="http://img<?php echo($str3); ?>.imageshack.us/img<?php echo($str3); ?>/<?php echo($str4); ?>/<?php echo($str5); ?>">';
</script>

error.php

<script type="text/javascript">
  alert("There was an error uploading the file.");
</script>