开发者

Pulling files from server in PHP to edit

I'm trying to resize a bunch of photos that have been previously uploaded via a web interface. The files are off the webroot like

/_uploads/filename.jpg

I search my DB and get all the urls for the photos then send them to my photo resizing class开发者_运维百科. I'm geting the following error:

Fatal error: Call to a member function load() on a non-object in (path to source)

I've tried both of these but neither work. This is on Window too if that helps...

Also the class works when resizing on upload.

// option 1
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) { 
    $curfile = "/_uploads/".$row['filename'];
    $image->load($curImage);
    // other stuff...
}

// option 2
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) { 
    $curfile = $_SERVER['DOCUMENT_ROOT']."/_uploads/".$row['filename'];
    $image->load($curImage);
    // other stuff...
}


First of all (as Adithya is saying), replace $curImage by $curfile. Besides that, you don't seem to initialize $image (that's what the error is saying). I don't know how your class is called, but say it's called Image, then you should add this above $image->load ...:

$image = new Image();


The problem is that $image is not an object. That's what you need to fix - the code you posted is pretty much unrelated to it since it doesn't initialize $image.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜