NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Test upload of image of 4,5 mb = No info


Joined: 08 Mar 2016
Posts: 8
Location: Sweden
Reply with quote
Hello

I changed the php.ini file to 5mb from 2mb
and then uploaded a image of 4,5 mb and did this

When debugging...
$name = $_FILES['filename']['name'];

but $_FILES Filename type contains nothing ?
I'v tried smaller images and it works. except if the suffix is in capital letters like .JPG
Then i have the same result

Is this a limitations of PhpED or is it something i'm missing?
The image was sent from a samsung 6 edge with gmail and then save to disk.

Brgds Stefan

_________________
SB
View user's profileFind all posts by webkeytemplateSend private message
Guru master

Joined: 24 Jul 2009
Posts: 710
Reply with quote
Nothing to do with PhpED or the debugger. I have *never* found either of those to interfere with running code, except the occasional strange problem when there are active watches in debug mode. That is not PhpED's fault, that was my fault and very unlikely to be the problem in this case.

Have you set both post_max_size and upload_max_size, with post_max_size being equal to or greater than upload_max_size?

http://php.net/manual/en/ini.core.php#ini.post-max-size

Code:
post_max_size = 5M
upload_max_size = 5M


If JPG does not work, it is possible that the PHP code for controlling the upload is doing something. PHP code can even change the $_FILES array if it wants to.

Is it your own code or from someone else?
View user's profileFind all posts by plugnplaySend private message


Joined: 08 Mar 2016
Posts: 8
Location: Sweden
Reply with quote
Hello

post_max_size = 8M

; Maximum allowed size for uploaded files. PhpED comes with 2M on install changed to 5M sp now it is
upload_max_filesize = 5M

The code is a mix of own code and copied from other developer
------------------------------------------------------------------------
This code when uploading a 4,5mb image.jpg will result in a false value when testing for mimetype.

A smaller image is ok. Tested with 1.5mb
------------------------------------------------------------------------

<?php
if ($_FILES)

{
$name = $_FILES['filename']['name'];
switch($_FILES['filename']['type'])
{
case 'image/pjpeg': $ext = 'jpg'; break;
case 'image/jpeg': $ext = 'jpg'; break;
case 'image/gif': $ext = 'gif'; break;
case 'image/png': $ext = 'png'; break;
default: $ext = ''; break;
}
if ($ext)
{
$gmtime = (int)gmdate('U');

$n = "upload/image.$ext";
move_uploaded_file($_FILES['filename']['tmp_name'], $n);
echo "Uppladdad bild '$name' as '$n': <br/> ";
echo "<img src='$n' /> ";

function compress_image($source_url, $destination_url, $quality) {
$info = getimagesize($source_url);
list($width, $height) = getimagesize($source_url);

if ($info['mime'] == 'image/jpeg') $image = imagecreatefromjpeg($source_url);
elseif ($info['mime'] == 'image/pjpeg') $image = imagecreatefromjpeg($source_url);
elseif ($info['mime'] == 'image/gif') $image = imagecreatefromgif($source_url);
elseif ($info['mime'] == 'image/png') $image = imagecreatefrompng($source_url);

//save it
imagejpeg($image, $destination_url, $quality);


return $destination_url;
}

$source_photo = "$n";
$dest_photo = "upload/image$gmtime.$ext";

$d = compress_image($source_photo, $dest_photo, 50);
echo "<img src='$d' /> ";

}
else echo " '$name' är inte en godkänd bildfil";
}
else echo " Ingen bildfil har blivit uppladdad";


?>

_________________
SB
View user's profileFind all posts by webkeytemplateSend private message
Guru master

Joined: 24 Jul 2009
Posts: 710
Reply with quote
The MIME file 'type' element is provided by the browser and not by PHP, so it can be incorrect, unset or even faked. It is possible that your browser is providing a different MIME type for jpg and JPG. What about using just the file extension for your checking?

Have you checked phpinfo() to ensure those max settings have been applied?

Have a look at this URL for some possible clues:

http://stackoverflow.com/questions/3586919/why-would-files-be-empty-when-uploading-files-to-php
View user's profileFind all posts by plugnplaySend private message


Joined: 08 Mar 2016
Posts: 8
Location: Sweden
Reply with quote
Hello plugnplay

Thanx for your help.
There were actually 2 php.ini files residing on my pc.
C:\Program\NuSphere\PhpED\php55 and C:\Program Files (x86)\NuSphere\PhpED\php5

First I made changes to the php.ini file under C:\Program Files (x86)\NuSphere\PhpED\php5.

But i used the phpinfo() to list the upload info. I found the other php.ini file under C:\Program\NuSphere\PhpED\php55

So after editing and increasing from 2M to 5M and restart Nusphere it worked fine to run a upload with a larger file.

BUT do you know how webserverhotels usually configure max upload configurations?
There is one thing to run it locally and another up there

Brgds Stefan

_________________
SB
View user's profileFind all posts by webkeytemplateSend private message
Guru master

Joined: 24 Jul 2009
Posts: 710
Reply with quote
If you are using shared hosting, you might not be able to change the maximum upload size but normally they would already be reasonable maximums. On our web servers we normally set at least 8GB. Some shared hosting control panels might even allow you to set your own maximums.

If you are using a dedicated or virtual server, you will probably be able to change any setting you like.

Bear in mind that whilst the built-in PhpED web server gives you normal PHP, it is not an Apache web server. Because Apache does interact with PHP such as setting certain PHP global variables, depending on what your code is doing it may find differences when running on Apache.

Ideally you should install the same type of web server as your hosting so that you can test properly. You can use a WAMP distribution for doing that, but if you already have a database server installed which you are happy with then you could instead use the NuSphere TechPlatform.
View user's profileFind all posts by plugnplaySend private message
Test upload of image of 4,5 mb = No info
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic