duansha8764 2011-01-26 12:15
浏览 215
已采纳

将变量从一个PHP文件传递到另一个PHP文件

I'm working on an image resizer, to create thumbnails for my page. The resizer works on principle of include a DIRECT link to the image. But what I want to do is put in the PHP Variable in the URL string, so that it points to that file and resizes it accordingly.

My code is as follows :

<img src="thumbnail.php?image=<?php echo $row_select_property['image_url']; ?>

Image Resize :

 <?php 
  // Resize Image To A Thumbnail

  // The file you are resizing 

  $image = '$_GET[image_url]'; 

  //This will set our output to 45% of the original size 
  $size = 0.45; 

   // This sets it to a .jpg, but you can change this to png or gif 
   header('Content-type: image/jpeg'); 

   // Setting the resize parameters
   list($width, $height) = getimagesize($image); 
   $modwidth = $width * $size; 
   $modheight = $height * $size; 

   // Creating the Canvas 
   $tn= imagecreatetruecolor($modwidth, $modheight); 
   $source = imagecreatefromjpeg($image); 

   // Resizing our image to fit the canvas 
   imagecopyresized($tn, $source, 0, 0, 0, 0, $modwidth, $modheight, $width, $height); 

    // Outputs a jpg image, you could change this to gif or png if needed 
    imagejpeg($tn); 
    ?>

What I am trying to do is pass on the variable "image=" to the Thumbnail script. At the moment I am passing it through the URL string, but it doesnt seem to load the graphic.

I'll try expand on this more, should you have questions as I am finding it a little difficult to explain.

Thanks in advance.

  • 写回答

3条回答 默认 最新

  • dongxian8272 2011-01-26 12:19
    关注

    Change it

     $image = '$_GET[image_url]'; 
    

    to

     $image = $_GET['image']; 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 这个公式写进SIMULINK中的function模块的代码中应该是什么样的
  • ¥15 javaweb登陆的网页为什么不能正确连接查询数据库
  • ¥15 数学建模数学建模需要
  • ¥15 已知许多点位,想通过高斯分布来随机选择固定数量的点位怎么改
  • ¥20 nao机器人语音识别问题
  • ¥15 怎么生成确定数目的泊松点过程
  • ¥15 layui数据表格多次重载的数据覆盖问题
  • ¥15 python点云生成mesh精度不够怎么办
  • ¥15 QT C++ 鼠标键盘通信
  • ¥15 改进Yolov8时添加的注意力模块在task.py里检测不到