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条)

报告相同问题?

悬赏问题

  • ¥20 access中怎么分割分别获取一下图中的值
  • ¥15 keras_tcn已经安装成功,还是显示ModuleNotFoundError: No module named 'keras_tcn'
  • ¥15 类图中关联与聚合的区别
  • ¥15 ENVI高分五号去除云层的方法
  • ¥15 16进制数据如何得到奇偶校验位
  • ¥15 求合并两个字节流VB6代码
  • ¥15 Pyqt 如何正确的关掉Qthread,并且释放其中的锁?
  • ¥30 网站服务器通过node.js部署了一个项目!前端访问失败
  • ¥15 WPS访问权限不足怎么解决
  • ¥15 java幂等控制问题