Jump to content

voip03

Members
  • Posts

    693
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

voip03's Achievements

Member

Member (2/5)

0

Reputation

  1. can you post me new code
  2. Missing <php ?> code in form . <?php $host="localhost"; $username="root"; $password=""; $db_name="dbreg"; $tbl_name="account"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB");$sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); echo "<table border=\"5\" width=\"400\" >";echo "<tr><th>List of Student to be approve</th>"; if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { echo "<tr><td>"; echo "<input type='checkbox' name='list[]' value='".$row['Username']."'>".$row['famname'].",".$row['gname']. ",".$row['mname']. ".<br/></td>"; echo "</tr></input>"; } } else { echo "<tr><td align=\"center\"> No Student to be Approve / Reject </td></tr>"; } echo'</form>'; ?>
  3. Have you written a code? if not please read this tutorials http://www.satya-weblog.com/2007/05/php-file-upload-and-download-script.html
  4. Have you connected to your MySQL database ?
  5. voip03

    Drawing a line

    Amit20,cssfreakie ,manuelV,wright67uk ! Thank you.
  6. Why not? Please read the article http://psoug.org/definition/DISTINCT.htm
  7. YOUR FULL CODE ( tested and it working) Main Page <?php /* "Warning: Cannot modify header information - headers already sent by " To avoid the header error , give value zero to $mosConfig_locale_debug = 0; $mosConfig_locale_use_gettext = 0; */ $mosConfig_locale_debug = 0; $mosConfig_locale_use_gettext = 0; ob_start(); /*This script can send an email and/or make an entry in a log file There are two variables below - one for an email address and one for a log file Set both variables to the values you want to use If you do not want either an email or log entry, comment out the respective line For example, if you do not want an email sent, put a // in front of the $emailAddress line - same for the $logFile line */ $logFile = $_SERVER['DOCUMENT_ROOT'].'/upload.log';// full path to your log $emailaddress = "email@gmail.com"; $home_page = "index.html"; // used for a link to return $uploaddir = "uploads/"; // the directory where files are to be uploaded - include the trailing slash $fileTypeArray = array(".jpg",".gif",".txt"); // enter in all lower case, the script will handle a match with upper case $maxSize = 500000; // maximum file size that can be uploaded - in bytes $maxFileSpace = 50000000; // maximum space that can be used by files matching the $fileTypeArray array in the upload directory - in bytes putenv('TZ=EST5EDT'); // eastern time// change nothing below this line $maxDisplay = $maxSize / 1000; ?> <html><head></head><body><div style="text-align: center; margin: 100px auto; border: 1px black solid; width:400px;"> <?php $file_name = $_FILES['file']['name']; $file_size = $_FILES['file']['size']; $file_tmp_name = $_FILES['file']['tmp_name']; if (!empty($file_name)) { unset($error); echo "<br>File Name: $file_name<br><br>"; echo "File Size: $file_size bytes<br><br>"; // file size test if ($file_size == 0 ) $error .= "<span style='color: red;'>Invalid file</span><br>"; if ($file_size > $maxSize ) $error .= "<span style='color: red;'>Your file exceeds $maxDisplay K.</span><br>"; // file type test if (!in_array(strtolower(strrchr($file_name,'.')),$fileTypeArray) ) $error .= "<span style='color: red;'>Your file is not a valid file type.</span><br>"; // max directory size test foreach(scandir($uploaddir) as $file_select) if (in_array(strtolower(strstr($file_select,'.')),$fileTypeArray)) $total_size = $total_size + filesize($uploaddir.$file_select); if (($total_size + $file_size) >= $maxFileSpace) $error .= "<span style='color: red;'>Total file space limits have been exceeded.</span><br>"; // scrub characters in the file name $file_name = stripslashes($file_name); $file_name = preg_replace("#[ ]#","_",$file_name); // change spaces to underscore $file_name = preg_replace('#[^()\.\-,\w]#','_',$file_name); //only parenthesis, underscore, letters, numbers, comma, hyphen, period - others to underscore $file_name = preg_replace('#(_)+#','_',$file_name); //eliminate duplicate underscore // check for file already exists if (file_exists($uploaddir.$file_name)) $error .= "<span style='color: red;'>File already exists.</span><br>"; // if all is valid, do the upload if (empty($error)) { if (move_uploaded_file($file_tmp_name,$uploaddir.$file_name)) { chmod($uploaddir.$file_name,0644); //echo "<span style='color: green;'>Your file was successfully uploaded!</span>"; /* 1st send the email confirmation to user 2nd redirect to display.php to show the image */ if (isset($emailAddress)) { $message = $file_name . " was uploaded by".$_SERVER['REMOTE_ADDR']."at".date('Y-m-d H:i:s'); mail($emailaddress,"You have a file upload",$message,"From: Website <>"); } if (isset($logFile)) { $logData = $file_name."||".$_SERVER['REMOTE_ADDR']."||".date('Y-m-d H:i:s')."\r\n"; @file_put_contents($logFile,$logData,FILE_APPEND|LOCK_EX); } ## redirect to display.php header("Location:display.php?imageName=".$file_name ); exit(); } else { echo "<span style='color: red;'>Your file could not be uploaded.</span>"; } } echo "$error<hr>";} ?> <p>Upload a <span style="color: blue;"> <?php foreach($fileTypeArray as $fileType) echo $fileType;?> </span> file to our server<br>Maximum file size is <?php echo $maxDisplay; ?>K</p> <form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post" enctype="multipart/form-data"> File: <input type="file" name="file" style="width: 250px;"><br> <input type="submit" name="submit" value="Upload File"> </form><a href="<?php echo $home_page; ?>">Return to the Home Page</a> display.php <?php // please validate the input $uploaddir = "uploads/"; // the directory where files are to be uploaded - include the trailing slash $file_name = $_GET['imageName']; echo "<img src='$uploaddir/$file_name' />"; ?>
  8. place this code top of codes. /* "Warning: Cannot modify header information - headers already sent by " To avoid the header error , give value zero to $mosConfig_locale_debug = 0; $mosConfig_locale_use_gettext = 0; */ $mosConfig_locale_debug = 0; $mosConfig_locale_use_gettext = 0; ob_start();
  9. header("Location:".$config_basedir ."display.php?imageName=".$file_name ); exit(); where is it?
  10. It may help http://www.phpfreaks.com/forums/index.php?topic=343181.msg1619002#msg1619002
  11. After this code. echo "<span style='color: green;'>Your file was successfully uploaded!</span>"; Add new code echo "<span style='color: green;'>Your file was successfully uploaded!</span>";echo "<img src='$uploaddir.$file_name' />"; $config_basedir="http://www.XXX.com/"; header("Location:".$config_basedir ."display.php?imageName=".$file_name ); exit(); display.php <?php // please validate the input $uploaddir = "uploads/"; // the directory where files are to be uploaded - include the trailing slash $file_name = $_GET['imageName']; echo "<img src='$uploaddir.$file_name' />"; ?>
  12. You want to upload the image and display in different page
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.