PHP Newsletter

Join now and receive weekly updates pertianing to the world of PHP.

Polls

What do you think about the new PHPMine Design?
Awesome
Not Bad
Sucks

PHP Gigs By City

PHP Jobs By Topic

Advertisements

How do you code this in php?

Asked 2010-03-09 10:56:00 by scarshin09

i have an 'edit function' on the website that i am working on.
the form of that page contains an upload of picture..

php1

<input type="file" name="pic" />
<input type="hidden" name="delpic" value="<SQL statement, retrieve filename >" />

---------------------------------------------------------

php2

if ($_FILES['pic']['type'] == "image/jpeg") {
if($file_size >= $limit_size)
echo "Your file size is over limit!";
else {
if(move_uploaded_file($_FILES['pic']['tmp_name'], $path)) {
$delpath = "photos/".$delpic;
unlink($delpath);
echo "Successful!";
}
else
echo "Sorry, there was a problem uploading your file.";
}
}
else {
echo "Bad File Type";
}


Question:

there are instances that the user will no longer want to change his picture.
how will php know that the there is no value for variable 'pic' in the first php code?

i only allow one picture. <the reason is another long story>^^

please do help me..^^

Anwered 2010-03-09 11:01:46 by Monkeyhybrid

PHP has a function called is_uploded_file() that will determine if a specified file was uploaded or not.

Take a look at http://php.net/manual/en/function.is-uploaded-file.php for example and explanation.

Anwered 2010-03-09 22:54:04 by Bill M.

Hi scarshin09,

This is not an answer to this question but I hope you don't mind. I just thought that this is the only way to make a follow up on your previous question about wired and wireless internet subscription. If you will be getting the 512kbps wireless in favor of the 384 wired, make sure that it doesn't have a limit on the amount of download and upload. Some ISPs I know offer higher speeds but cut you off or charge you extra once you exceed a monthly quota. Better clarify it with the ISP you are eying if it's unlimited or not.

Thanks.

Questions and answers provided by the Yahoo Answers Community.