Upload files

See all posts Reply

Upload files new!
by elxan, 15 years, 11 months ago
I write code for uploading file to directory. When I run code from easyphp all was ok
But when i upload the code to hosthing and then i run code the code couldnt upload file
What is matter? may it belongs of my PLESK options or else...

Please help me .Reply
Re: Upload files new!
by colin, 15 years, 11 months ago
Please refrain from posting the same message 10 times!!!

I can't answer your question if you don't provide me with more details. What does not work? Do you have any error messages? What is in the log of the class? What is in the PHP log?Reply
Another Resize Issue new!
by choffman, 15 years, 5 months ago
Hey Colin -
First off, thanks for putting together such a great script! The script seems to be working fine except for the resize function. Any ideas and help would be great. My code and log output is below:

$handle = new upload($_FILES['img_field']);
$handle->image_resize = true;
$handle->image_x = 75;
$handle->image_ratio_y = true;
$handle->jpeg_quality = 70;
$handle->file_new_name_body = 'member_image';
$handle->file_safe_name = true;
$handle->file_auto_rename = true;
$handle->image_convert = 'jpg';
$handle->file_max_size 	= true;
$handle->dir_auto_chmod = true;
$handle->dir_chmod = 0777;
$handle->Process('images/users/');
if ($handle->processed) {
  echo('Your image has been renamed, resized and converted to JPG.');				    
  $handle->Clean();
  echo(''.$handle->log.'');
} else {
   echo 'error: ' . $handle->error;
}

The log:
system information
- GD version : 2.0.34
- supported image types : png jpg gif bmp
- open_basedir : no restriction
- language : en_GB
source is an uploaded file
- upload OK
- file name OK
- MIME type detected as regular file by UNIX file() command
- source variables
file_src_name : test.png
file_src_name_body : test
file_src_name_ext : png
file_src_pathname : /private/var/tmp/phpKpWqw2
file_src_mime : regular file
file_src_size : 36021 (max= 2097152)
file_src_error : 0
process file to images/users/
- file size OK
- file mime OK : regular file
- new file name ext : jpg
- new file name body : member_image
- file name safe format
- destination variables
file_dst_path : images/users/
file_dst_name_body : member_image
file_dst_name_ext : jpg
- no image operation, keep extension
- checking for auto_rename
auto_rename to member_image_1.jpg
- destination file details
file_dst_name : member_image_1.jpg
file_dst_pathname : images/users/member_image_1.jpg
- member_image_1.jpg doesn't exist already
- no image processing wanted
- process OK
cleanup
- delete temp file /private/var/tmp/phpKpWqw2
Reply
Re: Another Resize Issue new!
by colin, 15 years, 5 months ago
The log says:
- MIME type detected as regular file by UNIX file() command
- file mime OK : regular file
- no image processing wanted


That means that the UNIX file command returned regular file as a MIME type, which is not correct. And then the class doesn't think that the file is a valid image, and deactivate image processing. which is why the file is uploaded, but not resized.

Could you please send me the picture privately, and also indicate here which OS you are running the script on?

What do you get if you run in a shell:
file -bi your_image.jpg
You should get a MIME type here, but in your case you seem to get regular file.Reply
Re: Another Resize Issue new!
by BPierre, 15 years, 3 months ago
I have the same problem (regular file), on OS X 10.5.Reply
Re: Upload files new!
by BPierre, 15 years, 3 months ago
Log :

- MIME type detected as regular file by UNIX file() command
...
file_src_mime : regular file


Terminal :

$ file -bi image.jpg
image/jpegReply
Re: Upload files new!
by colin, 15 years, 3 months ago
Thank you for the test.

I am quite surprised, because PHP executes file -bi image.jpg in the class code, through shell_exec, and gets regular file. But if you run it at the command line, you have image/jpeg. There is something weird on MacOS, but I don't have a machine to investigate.

In the meantime, you can comment the block of code underneath: "// checks MIME type with shell if unix access is authorized". This will deactivate this method of MIME detection, and the class should work again.Reply