duan0504 2015-04-16 18:28
浏览 21
已采纳

如何通过php存储转储信息[关闭]

I want to store images created by php in real time. Currently each image is destroyed after creation, but instead I want to store the images in an unique folder on my website.

I have seen many websites that use a dedicated dump folder, e.g. http://www.example.com/dump/4592898349.jpg, and I was wondering if someone could explain to me how I could do that.

This is my html code with the form that starts the image generation:

<html>
    <body>
        <form action="result.php" method="get">
            <input type="text" name="name" id="name">
            <input type="button" name="submit" id="submit">
        </form>
    </body>
</html>

And here is my php code, which creates the image with the given text:

<?php
    header('Content-type: image/jpeg');
    $jpg_image = imagecreatefromjpeg('Desert.jpg');
    $white = imagecolorallocate($jpg_image, 73, 41, 236);
    $font_path = 'OpenSans-Italic.TTF';
    $text = $_GET['name'] ;
    imagettftext($jpg_image, 25, 0, 75, 50, $white, $font_path, $text);
    imagejpeg($jpg_image);
    imagedestroy($jpg_image); 
?>

However, I still don't know where would be the best place to save the image.

  • 写回答

2条回答 默认 最新

  • duangenshi9836 2015-04-16 18:45
    关注

    change

    imagejpeg($jpg_image);
    

    to

    imagejpeg($jpg_image,"imagefolderpath/image.jpg");
    

    that will write the image to file, and not output the image...so...

    $image_url="dump/".rawurlencode(trim($text)).".jpg";
    imagejpeg($jpg_image,$image_url);
    readfile($image_url);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题