Closed spaceemotion closed 10 years ago
Can you give me a stack trace? I'd like to see where this is occurring at inside the Resizer class.
Umm, might be a weird question, but how do I print a stacktrace in this case? I don't have xDebug or some other debugger installed, and the above message is all I get as return value…
Where are you seeing this at? Is it throwing an error in the browser that you can see (with whoops) ? Why is your error in JSON format? I'm just trying to wrap my head around where this is happening at.
Well, what I'm having is a drag-and-drop zone using the filezone jQuery plugin. I just set the url to be correctly and added some more stuff to show progress bars and such.
The error gets thrown as JSON, I do not know why this happens, but it does. The upload function in my gallerycontroller is only this small piece of Code:
public function upload($hashId)
{
$gallery = Gallery::findOrFail($this->getId($hashId));
$file = Input::file('file');
$picture = new Picture;
$picture->picture = $file;
if ($gallery->pictures()->save($picture))
{
return Response::json('success', 200);
} else {
return Response::json('error', 400);
}
}
Even though I declared my _responses_ as JSON, the error gets thrown during the save process (I also removed my responses completely, just for the fun of it, got a JSON error again…).
When I was looking at the actual response and request headers, this is what I got:
Request header:
POST /user/gallery/upload/yAePIE2Q HTTP/1.1
Host: localhost
Connection: keep-alive
Content-Length: 397520
Origin: http://localhost
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36
content-type: multipart/form-data; boundary=------multipartformboundary1394182659981
Accept: */*
Referer: http://localhost/user/gallery/yAePIE2Q/edit
Accept-Encoding: gzip,deflate,sdch
Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Cookie: laravel_session=eyJpdiI6InVxanppVGc4SWZ1N0JOeUN6eDVRMnhyWEdpYWRhcldHcE00cFwvaXZkMUhjPSIsInZhbHVlIjoiRXNHc0FjdUJyWTZsUFlPcEhyVk5TS3NjXC9nK2NsTEZoUWViZ3dmd2VTUnJjMUJJREo2eGtoZlVNRTJ1SGowNlpqVmxtS1Y3d2NKdytzRnpzVHB5aXF3PT0iLCJtYWMiOiI1NTEwOGE3N2QwZTJkNDdiOWRlZDQ2MmVkYWIzZTYwZDNmM2NiNjNkMDZjNjEwZDdiMmViYzFkNTg5M2NhZWIxIn0%3D
Request Payload
--------multipartformboundary1394182659981
Content-Disposition: form-data; name="file"; filename="IMG_0014.JPG"
Content-Type: image/jpeg
ÿØÿá?þExifMM*
ª°¼Ä(1Ì2Ø<ì (and a whole bunch more of these)
--------multipartformboundary1394182659981--
Response header:
HTTP/1.0 500 Internal Server Error
Date: Fri, 07 Mar 2014 08:57:40 GMT
Server: Apache
X-Powered-By: PHP/5.5.3
Cache-Control: no-cache
X-Frame-Options: SAMEORIGIN
Set-Cookie: laravel_session=eyJpdiI6IlwveFh1VnhYUW5uK0xSVzVoZVZcLzRqRVBTWVVCQ1wvQ0NRMjJhZEF4cDRQUVE9IiwidmFsdWUiOiJtOGpzNFwvdFh4WXdCN0tPZFFDWFErTmFhYkRGazVTSTVBb29QWFA1cG1ya3J2aDZNQVhCRG5mNXcrcUYranhsZkIwQ1wvTzhPd1FVVGRzVmRRMTg3QmlBPT0iLCJtYWMiOiI3ZGJiMDEwZTk4MzRiZTI2MjcxMWM4MDRkYTA5OTU1MWE5MDI3MTcyODZiN2U1NmI5YTNmZWMzNjk2MTNkMDE5In0%3D; expires=Fri, 07-Mar-2014 10:57:44 GMT; Max-Age=7200; path=/; httponly
Connection: close
Content-Type: text/html
As you can see, although It outputs a JSON string, the actual response content type is still plain HTML. I do not know if this is an error by Imagine or not, but it sure is crazy.
Well, every file that gets resized with Imagine is resized/save in php's tmp file directory and then moved to it's new location after that. I have a very strong feeling that your tmp directory isn't writeable by php, but I can't verify this (and you say that you've checked it already). Are you able to upload files with stapler using a non-ajax request?
Okay well that is weird. I was using the Imagine library for resizes on the same machine (my localhost), but on a different project. I added some really quick-n-dirty user avatar option, tried uploading a new image and got this stacktrace:
_"Imagine \ Exception \ RuntimeException imagejpeg(.IMG_0007.JPG): failed to open stream: Permission denied"_
Yeah, your php tmp directory isn't writeable. Keep in mind, writing to the tmp directory isn't an Imagine Image convention (Imagine doesn't really care where you tell it to write images to), it's something I'm having stapler do before files are moved to their final location on the file system. It's better to break file processing down into atomic resizing/processing and moving operations (due to the various file storage options).
Okay, so I had do some other things, but I finally got back to this.
I tried several other sites of mine that are not using stapler. They all uploaded images just perfectly fine. Even when I set my php tmp directory to 077 I still got the permission denied error.
If this can't be fixed (I don't know what could cause that either :( ), I might have to switch to a different package - but I like stapler for its simplicity!
Wow. I'm speechless.
Since Apple had to wipe my hard-drive on a recent repair I decided to use a Vagrant setup this time (I was using MAMP Pro before). Turns out: it works. I don't know why it's not working on a MAMP _Pro_ setup, but using a custom puphpet version (plus php5-gd installed) it worked flawlessly.
Thanks anyway lol.
Im currently trying to incorporate a small gallery system into my application. Users can upload pictures to galleries and the pictures are getting resized to 3 different sizes for the thumbnail view, medium view and full view.
My upload part of my function looks like this:
The image gets added to the database correctly and the
uploads/
folder is 0777-chmodded as well. So no big deal there. However, the real problem I'm having is completely unclear to me:The php-tmp folder is writable as well, I tested that through other applications.
Why do I still get a permission denied? What am I doing wrong?