[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

09/13/2005 at 12:04AM PDT, ID: 21559254
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.6

No image checkbox on Diablo88s uploading script

Asked by lindhansen in PHP and Databases

How can I expand Diablo84`s nice script on uploading files with a checkbox that let users
choose a default image if they have no image to upload.Something like:



if ((empty($file_name)) and (empty($no_image)))
{
  $error[] = "No file has been selected";
}



I have placed a default.jpg image in the uploadfolder.


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

<?php
if(array_key_exists('submit',$_POST)) {

 $allowed_files = array('image/gif','image/pjpeg','image/jpeg','image/jpg','image/png');
 $file_max = 51200; //1mb = 1048576 | 512kb = 524288 | 50kb = 51200
 $upload_path = $_SERVER['DOCUMENT_ROOT']."/pictures/"; //upload folder - make sure this folder has write permission!!!!!

 $file_name = $_FILES['upload']['name'];  
 
 $error = array();

 if (empty($file_name)) {
  $error[] = "No file has been selected";
 }
 else {
  if (!in_array($_FILES['upload']['type'],$allowed_files)) $error[] = "File type is not allowed";
  if ($_FILES['upload']['size'] > $file_max) $error[] = "File size is too big";
  if (file_exists($upload_path.$file_name)) $error[] = "A file with this name already exists";
 }

 if (count($error) == 0) {
  move_uploaded_file($_FILES['upload']['tmp_name'], $upload_path.$file_name) or die("Error Completing Request");
  echo "File Upload Complete<br>";
 }
 else {
  echo "The following errors occured\n<br>";
  foreach ($error as $var) echo " - $var<br>\n";  
 }

}
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="uploadfile" enctype="multipart/form-data">
<input name="upload" type="file" size="40">
<input name="submit" type="submit" value="Upload">

===========-------------------------===============================

<input name=\"no_image\" type=\"checkbox\" value=\"default.jpg\">

=============-----------------------=================================


</form>




$fb = $_FILES['upload']['name'];
$fb = $no_image;
$db->sql_query("INSERT INTO far VALUES (NULL,'$username','$fb','$f1','$f2')");


And if the user activate the checkbox this will change the insert query to $fb = $no_image

Or do you have a better solution?
 
Loading Advertisement...
 
[+][-]09/13/05 08:29 AM, ID: 14872665

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/13/05 09:50 AM, ID: 14873501

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/13/05 02:49 PM, ID: 14876164

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/14/05 10:00 AM, ID: 14882514

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/14/05 01:46 PM, ID: 14884742

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/14/05 02:41 PM, ID: 14885234

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/14/05 03:11 PM, ID: 14885408

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP and Databases
Sign Up Now!
Solution Provided By: WoodyRoundUp
Participating Experts: 1
Solution Grade: A
 
 
[+][-]02/08/06 02:39 AM, ID: 15901068

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]02/12/06 11:02 AM, ID: 15935987

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20090824-EE-VQP-74