dongzhong7299 2013-09-11 08:53
浏览 372

当发布非常长的base64字符串时,表单占用太多时间

Our PHP script is hosted on Linux based Apache Server. I have a form with one textarea and a submit button. This textarea contains a very long base64 string of 284312 characters.

When I submit this form it takes too much time. It is still processing after a very long time. It is working for small base64 string and images are posted successfully but it is not working with large size images base64 string.

I am using following code on server side to get this base64 image:

$ifp = fopen( "images/myimage.png", "wb" );
$status = fwrite( $ifp, base64_decode( str_replace(' ', '+', $_REQUEST['image'] ) ) );
fclose( $ifp );

Is there any solution for this? Should I change anything in my PHP or Apache configuration ?

  • 写回答

1条回答 默认 最新

  • dtlc84438 2013-09-11 09:26
    关注

    Try it without $_REQUEST, my complete script first, here is the code which works fine for me, if it does not work for you, then provide complete info about PHP/webserver/machine (os, cpu..): But I think it is something about passing chars from your textarea to the code, I did not get it well how you do it, but testing script below gives us answers :)

    <?php
        $time_start = microtime(true); 
    
        $imagedata = file_get_contents('Cat2.jpg'); //5616998 bytes
        $base64 = base64_encode($imagedata);
    
        //echo strlen($base64); //7489332 characters
    
        $ifp = fopen('myimage.png', 'wb');
        $status = fwrite($ifp, base64_decode(str_replace(' ', '+', $base64)));
        fclose($ifp);
    
        echo 'Total execution time in seconds: ' . (microtime(true) - $time_start); //0.098897218704224 seconds
    ?>
    

    More posted in comments before.

    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)