dsfdsf21312 2014-02-05 16:00
浏览 47

一种缩短我的URL字符串的方法

I have a string that represents an 812 bit file as a hex string. I'm trying to pass this in some way to a php script that will force a download of the file. The problem is that the URL string is too long. The length of just the hex string is 1624. Is there some sort of encoding or encryption I can use to shorten the string and still be able to get the expected result on the php side? I have tried sending json with an Ajax request, but I don't believe I can force a download that way.

JS:

var cfg = '';
for (var x = 0; x < relayBytes.length; x++)
{
    var str = relayBytes[x].toString(16);
    if (str.length === 1) str = '0' + str;
    cfg += str;
}
window.location = '../script.php?relay=' + cfg;

relayBytes is an int array with a length of 812.

PHP:

<?php
header('Content-Type: application/octetstream; name="file.txt"');
header('Content-Type: application/octet-stream; name="file.txt"');
header('Content-Disposition: attachment; filename="file.txt"');
echo $_GET['relay'];
?>
  • 写回答

1条回答 默认 最新

  • dqjmq28248 2014-02-05 16:05
    关注

    you can use the POST method to pass the data from one page to another page and also there many no of 3rd party services which provide you URL shortner service. You can also use their service but I will prefer you to use form post method to pass the data.

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?