Uploading One File Two Different Ways

See all posts See thread Reply

Re: Uploading One File Two Different Ways new!
by Erik Greif, 10 years, 5 months ago
Worked great!
But.. now back to the first problem. If I am running out of memory (on the larger files it still times out) what should I do? The file I am uploading is less than 1.5 megabytes. I have plenty of memory on my server system, I'm just not sure how to allocate more.Reply
Re: Uploading One File Two Different Ways new!
by colin, 10 years, 5 months ago
Search for memory in the site, or click here.

You can also check this post.

You need to raise the PHP memory limit, usually in php.ini. On shared hosting, you probably can't edit your php.ini, so you can try the following, although it will work only if the hosting company allows it, which they usually don't.

You can add this in your script:
ini_set ( "memory_limit", "40M")

Or in a .htaccess file:
php_value memory_limit 40M

If the above doesn't work, ask your hosting company.Reply
Re: Uploading One File Two Different Ways new!
by Erik Greif, 10 years, 5 months ago
I am currently hosting this at my own server since the domain doesn't exist yet. I think GoDaddy will have such options already turned up when I use them.
However on my server when I add that line to the script, the page works fine until I click upload, and then I get a blank page.
I've determined that the script dies right at the first
if ($handle->processed) { 
( dunno if the BBS is going to work )
Any ideas?Reply
Re: Uploading One File Two Different Ways new!
by colin, 10 years, 5 months ago
Check your webserver's log. You are probably running out of memory.Reply
Re: Uploading One File Two Different Ways new!
by Erik Greif, 10 years, 5 months ago
No. My PHP memory limit is set to "memory_limit = 128M" so I don't think that's the problem. Sorry to drag this out, but do you have any other ideas?Reply
Re: Uploading One File Two Different Ways new!
by colin, 10 years, 5 months ago
128MB may not be enough for images with a lot of pixels.

Besides, your webserver's log will tell you why the script crashes.Reply
Re: Uploading One File Two Different Ways new!
by Erik Greif, 10 years, 5 months ago
I am getting no info errors in Apache, but PHP just has the error I saw on screen.

[20-Jun-2014 15:02:48 US/Pacific] PHP Fatal error: Maximum execution time of 30 seconds exceeded in F:\Software Development\(PHP) SpychMed International\HTDOCS\scripts\upload\class.upload.php on line 5006

I have another domain with GoDaddy, which is where this is going to end up. So I just tested the code again, and while it took ages to upload, it did. Since we're here, might I ask how to set a maximum size (dimensions) for an upload? That way I can have a large image version, but it won't be over a certain number of pixels, like width*length.Reply
Re: Uploading One File Two Different Ways new!
by colin, 10 years, 5 months ago
I see, I missed your error. Your server seems quite slow. Anyhow, you can increase the PHP time limit in your script.

As for limiting the images that can be uploaded, check out image_max_width, image_max_height, and image_max_pixels.Reply
Re: Uploading One File Two Different Ways new!
by Erik Greif, 10 years, 5 months ago
Oh yes, my network card is having a lot of trouble. I get about 2 maybe 3 megabits up and down right now at best. Just awful. I'll be replacing it soon. However, I don't want to necessarily block large images. I want to downsize large images that are over a certain number of pixels.Reply
Re: Uploading One File Two Different Ways new!
by Erik Greif, 10 years, 5 months ago
It seems as if image_ratio, image_x, and image_y can achieve an image under a given width and height... am I right?
Just reading the documentation. Very unusual behavior for me.Reply
Re: Uploading One File Two Different Ways new!
by colin, 10 years, 5 months ago
I am not too sure I understand what you mean by "achieve".

image_ratio_xxx, image_x and image_y are used to resize an image.

Note that when you instantiate the class, you can read the images data with image_src_x, image_src_y and image_src_pixels and act accordingly.Reply
Re: Uploading One File Two Different Ways new!
by Erik Greif, 10 years, 5 months ago
Okay so all of the above worked great with an if check on the original resolution. ALL GOOD :) Starting a new topic for something else though.Reply