donglei1699 2011-09-07 01:58
浏览 365
已采纳

为什么不能将imagejpeg保存到文件夹中?

I've been truble shooting this for hours and i've been all over the web trying to find the solution to this... Im writing a thumbnale generater in php that should generate a gray scale image and a non gray scale, but i've been running into this error. I have already changed my permissions to 777 and chown to nobody and admin. and this function works as long as I over write an image by the same name, but it cannot store in a file for some reason.

here is the error:

imagejpeg() [function.imagejpeg]: Unable to open '/Applications/XAMPP/xamppfiles/htdocs/images
/thumb/rollover' for writing: Is a directory

here is the code i'm working with.

  $img = imagecreatefromjpeg($grayscale_path);

            imagefilter($img, IMG_FILTER_GRAYSCALE);

            imagejpeg($img, realpath($this->gallery_path .'/thumb/rollover/'));


            imagedestroy($img);

also i've checked many many times to see if the path is correct and it is.

  • 写回答

2条回答 默认 最新

  • dongtun3328 2011-09-07 02:01
    关注

    You need to append a filename,

     header("Content-type: image/jpeg"); 
     imagejpeg($img, realpath($this->gallery_path .'/thumb/rollover/filename.jpg'));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)