You are here: Re: 3 Questions About Image Uploading « All PHP « IT news, forums, messages
Re: 3 Questions About Image Uploading

Posted by J.O. Aho on 07/01/06 14:34

Kirilenko wrote:
> 1. I have MAX_FILE_SIZE listed in the form. If the file is over that
> size, the file doesn't upload, but what variable is used to check
> that? I have tried ($file is the variable of the file)
> $file_size>512000 but that doesn't work, as $file_size is 0. I gather
> that is because the file doesn't upload none of the $file variables
> have values. I want to be able to inform the user that the file didn't
> upload because of that.

As you got it, if the file size is bigger than the size you set in the form,
it won't be uploaded, which leads to your $file_size variable is 0.

You can inform the user that either communication failed or the file is bigger
than the allowed size if you find that $file_size is 0.


> 2. Is there a way to check the file-type before uploading it (similar
> to MAX_FILE_SIZE for size). I know the file still uploads, but it
> wouldn't store it on the server. Is there anyway to just accept
> image/jpeg and image/pjpeg? Currently I use $file_type to determine
> the type and if it's not of type image/jpeg or image/pjpeg I delete it
> using unlink. Also why do JPG files have 2 different types and all
> other image formats just one?

You would need to add javascript for that part, as that check has to be done
on the client side, as soon you do something on the server side, the file
would already been uploaded.


> 3. I didn't think you needed to use unlink if you used
> move_copied_file to move the files you uploaded, but someone recently
> told me that you did. Do you need to use it?

According to the example that you can find in the online manual, you don't,
http://www.php.net/manual/en/features.file-upload.php

You can look at some other pages for more information
http://www.php.net/manual/en/function.move-uploaded-file.php
http://www.php.net/manual/en/function.is-uploaded-file.php

Don't forget the user comments as those usually include good advice.


//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация