Jump to content

Chrisj

Members
  • Posts

    551
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Chrisj

  1. Thank you for your reply. I changed the duplicated lines to this: <li style="width:240px; text-align:right;"><strong>[var.lang_tags]2:</strong></li> <li style="width:400px; text-align:left;"><input name="tags2" type="text" class="upload-video-form-input" value="[var.tags]" size="38" /> Buy I can't find what is entered into Tags2 field when I search. The mysql has a column named 'tags', so do you think I'd be on the right track if I added a column named 'tags2' in that db, and then add 'tags2' to this line in the search.php file: $type_query_rows = 'indexer, video_id, title, title_seo, date_uploaded, user_id, video_length, approved, public_private, description, tags, number_of_views'; I look forward to any guidance. Much thanks
  2. I'm using the phpMotion script and trying to add a 2nd "tag" field to the Upload Video Form. (The 'tag' field is for entering tags or search words, so the video can be found when searching). <li style="width:240px; text-align:right;"><strong>[var.lang_tags]:</strong></li> <li style="width:400px; text-align:left;"><input name="tags" type="text" class="upload-video-form-input" value="[var.tags]" size="38" /> </li> I copied and duplicated that code, like so: <li style="width:240px; text-align:right;"><strong>[var.lang_tags]:</strong></li> <li style="width:400px; text-align:left;"><input name="tags" type="text" class="upload-video-form-input" value="[var.tags]" size="38" /> </li> <li style="width:240px; text-align:right;"><strong>[var.lang_tags]2:</strong></li> <li style="width:400px; text-align:left;"><input name="tags" type="text" class="upload-video-form-input" value="[var.tags]" size="38" /> </li> But upon submitting the Form, Tags2: (the duplicated line) was required to proceed, not the original Tag field. Can you tell me what else I need to do to create a second (required) Tag field?
  3. After installing a PHP script, I see this // after the domain name in browser bar, for example www.awebsite.com//index.php How can I fix this?
  4. Thanks for your reply. Is this "the list of columns"? $sql = "INSERT into member_profile (email_address, user_name, password, passwordSalt, first_name, last_name, zip_code, country, user_ip, birthday, account_status, account_type, date_created, random_code)
  5. Can you help me figure out why I'm getting this: "Column count doesn't match value count at row 1"? thanks <?php error_reporting (0); include_once ('classes/config.php'); include_once ('includes/reserved_names.php'); $user_ip = mysql_escape_string($_SERVER['REMOTE_ADDR']); if ( $enable_forum == 1 ) header("Location: " . $smf_bridge_register); $send_confirm_email = $config['enabled_features_confirmation_email'] ; // define access for loading non display php files define('access',true); $ahah = 1; $show_register = ''; $load_ajax = ''; $form_submitted = ''; $action = ''; $new_user_name = ''; $account_type = ''; $first_name = ''; $last_name = ''; $email_address = ''; $email_address2 = ''; $user_name = ''; $password = ''; $confirm_password = ''; $country_list = ''; $dob_month = ''; $dob_day = ''; $dob_year = ''; $zip_code = ''; $birthday = ''; $error_message = ''; $checked = ''; $show_register = 1; $load_ajax = 1; $procede = true; $action = mysql_real_escape_string( $_GET['action'] ); $new_user_name = mysql_real_escape_string( $_GET['new_user_name'] ); $site_name = mysql_real_escape_string($config['site_name']); $form_submitted = mysql_real_escape_string( $_POST['form_submitted'] ); $max_len_username = (int)$config['max_username_length']; if ( $action == 'check_user' ) { $new_user_name = trim(strtolower($new_user_name)); if ( $new_user_name == '' ) { echo "<font color=\"#EE0000\" size=\"2\"><b>".$config['fill_all_fields']."</b></font>"; die(); } if ( strlen($new_user_name) < 4 ) { echo "<font color=\"#EE0000\" size=\"2\"><b>".$config['username_4_chars']."</b></font>"; die(); } if ( strlen($new_user_name) > $max_len_username ) { echo "<font color=\"#EE0000\" size=\"2\"><b>".$config['username_to_long']."</b></font>"; die(); } // check against reserved names e.g. -> admin etc... or adult words ban if ( in_array( $new_user_name, $reserved_names ) ) { echo "<font color=\"#EE0000\" size=\"2\"><b>".$config['username_not_allowed'] .""; die(); } $sql = "SELECT user_name FROM member_profile WHERE user_name = '$new_user_name'"; $query = @mysql_query($sql); $count = @mysql_num_rows($query); if ( $count > 0 ) { echo "<font size=\"2\"><b>$new_user_name</b></font><font color=\"#EE0000\" size=\"2\"> <b>=> $lang_not_available</b></font>"; } else { echo "<font size=\"2\"><b>$new_user_name</b></font><font color=\"#00DD00\" size=\"2\"> <b>=> $lang_available </b></font>"; } @mysql_free_result($result); @mysql_close(); die(); } if ( $action == 'show_country' ) { $country_fields_all = ''; $show_fields = ''; $country_list = file('includes/country.list'); foreach ( $country_list as $country_select ) { $country_fields_all = $country_fields_all . $country_select; } $show_fields = '<div style="margin-left:30px; float:left;"><b>'.$lang_country.':</b></div>'; $show_fields .= '<div style="margin-left:95px; float:left;" id="country_list">'; $show_fields .= '<select class="FormSpecialInput_1" id="country_list" name="country_list" style="font-size: 9pt; width:128px; height:20px; font-weight:bold; color:#444444; letter-spacing: 1; border: 1px solid #DFDCDC; background-color: #FDFDFD">'; $show_fields .= $country_fields_all; $show_fields .= '</select></div>'; echo $show_fields; die(); } if ( $procede == true ) { $account_type = 'Standard'; $first_name = trim(mysql_real_escape_string( $_POST['first_name'] )); $last_name = trim(mysql_real_escape_string( $_POST['last_name'] )); $email_address = trim(mysql_real_escape_string( $_POST['email_address'] )); $email_address2 = trim(mysql_real_escape_string( $_POST['email_address2'] )); $user_name = trim(mysql_real_escape_string( $_POST['user_name'] )); $password = trim(mysql_real_escape_string( $_POST['password'] )); $confirm_password = trim(mysql_real_escape_string( $_POST['confirm_password'] )); $country_list = trim(mysql_real_escape_string( $_POST['country_list'] )); $dob_month = (int) mysql_real_escape_string( $_POST['dob_month'] ); $dob_day = (int) mysql_real_escape_string( $_POST['dob_day'] ); $dob_year = (int) mysql_real_escape_string( $_POST['dob_year'] ); $zip_code = (int) mysql_real_escape_string( $_POST['zip_code'] ); if ( $_POST['terms'] == 'yes' ) { $checked = 'checked=\"checked\"'; $procede = true; } else { $procede = false; $error_message = $config['agree_to_terms']; } if ( strlen($user_name) < 4 ) { $error_message = $config['username_4_chars']; $procede = false; } if ( strlen($user_name) > $max_len_username ) { $error_message = $config['username_to_long']; $procede = false; } // check against reserved names e.g. -> admin etc... or adult words ban if ( in_array( $user_name, $reserved_names ) ) { $error_message = $config['username_not_allowed']; $procede = false; } // dDB birthday must be this format =>2008-09-17 $birthday = $dob_year .'-'. $dob_month .'-'. $dob_day; foreach ($_POST as $key => $value) { if (!isset($value) || ($value == '')) { $display_key = @str_replace('_', ' ', $key); if ( $display_key == 'zip code' && $value == '' ) { $value = 'none'; } else { $error_message = $error_message . ' - ' . $display_key . ' '.$lang_required.' '; $procede = false; } } else { if ( $key == 'email_address2' ) $key = 'email_address'; if ( $key !== 'email_address' && (!eregi("^[ _a-zA-Z0-9-]*$", $value)) ) { $display_key = @str_replace('_', ' ', $key); $error_message = $error_message . ' - ' . $display_key . ' '.$config['invalid_email_text'].' '; $procede = false; } if ( $key == 'email_address' && !eregi("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-z]{2,3})$", $value) ) { $display_key = @str_replace('_', ' ', $key); $error_message = $error_message . ' - ' . $display_key . ' '.$config['invalid_email_format'].' '; $procede = false; } if ( $key == 'user_name' ) { // check against reserved names e.g. -> admin etc... or adult words ban if ( in_array( $user_name, $reserved_names ) ) { $display_key = @str_replace('_', ' ', $key); $error_message = $error_message . ' ' .$config['username_not_allowed'] . ' !'; $procede = false; } } } } } // checking if emails match if ( $procede == true ) { if ( $email_address !== $email_address2 ) { $error_message = ' '.$config['emails_do_not_match']; $procede = false; } } // checking if passwords match if ( $procede == true ) { if ($confirm_password !== $password) { $error_message = ' '.$config['password_do_not_match']; $procede = false; } } // checking if username and email is unique if ( $procede == true ) { $sql = "SELECT user_name, email_address FROM member_profile"; $query = @mysql_query($sql); while ($result = (@mysql_fetch_array($query))) { if ( !empty($result['user_name']) || !empty($result['email_address']) ) { // case insensitive login and registration $reg_user_name = strtolower($user_name); $db_user_name = strtolower($result['user_name']); if ($db_user_name == $reg_user_name) { $error_message = ' '.$config['username_is taken']; $procede = false; } if ( $result['email_address'] == $email_address ) { $error_message = $error_message . ' -'.$config['email_already_exists']; $procede = false; } } } } // if any errors display error message => [var.message_type] - [var.error_message] if ($procede == false && $form_submitted == 'yes') { $message_type = $lang_error; $blk_notification = 1; $show_signup = 1; $template = "themes/$user_theme/templates/main_1.htm"; $inner_template1 = "themes/$user_theme/templates/inner_signup_form.htm"; $TBS = new clsTinyButStrong; $TBS->NoErr = true; $TBS->LoadTemplate("$template"); $TBS->Render = TBS_OUTPUT; $TBS->Show(); @mysql_close(); die(); } // START => load page with form if ( !isset($form_submitted) || ($form_submitted == '') ) { $show_signup = 1; $template = "themes/$user_theme/templates/main_1.htm"; $inner_template1 = "themes/$user_theme/templates/inner_signup_form.htm"; $TBS = new clsTinyButStrong; $TBS->NoErr = true; $TBS->LoadTemplate("$template"); $TBS->Render = TBS_OUTPUT; $TBS->Show(); die(); } // if no errors register user and load welcome page if ($procede == true) { if ( strtolower($_POST['captext']) != strtolower($_SESSION['security_code']) ) { // POSSIBLE BOT ATTACK => TODO: ADD SECURITY LOG ACTIONS ETC.... // LOADING TEMPLATE IS MAYBE USELESS SINCE THIS WOULD COME FROM A SCRIPT POST // MAYBE SHOULD JUST DO A DIE HERE! $message_type = $lang_error; $blk_notification = 1; $show_signup = 0; $template = "themes/$user_theme/templates/main_1.htm"; $inner_template1 = "themes/$user_theme/templates/inner_signup_form.htm"; $TBS = new clsTinyButStrong; $TBS->NoErr = true; $TBS->LoadTemplate("$template"); $TBS->Render = TBS_OUTPUT; $TBS->Show(); @mysql_close(); die(); } else { $random_code = randomcode(); $password_email = $password; $password = md5($password); $passwordSalt = substr(md5(rand()), 0, 4); if ( $zip_code > '' ) $country_list = 'USA'; if ( $send_confirm_email == 'yes' ) { // insert new user record $sql = "INSERT into member_profile (email_address, user_name, password, passwordSalt, first_name, last_name, zip_code, country, user_ip, birthday, account_status, account_type, date_created, random_code) VALUES ('$email_address', '$user_name', '$password', '$passwordSalt', '$first_name', '$last_name', '$zip_code', '$country_list', '$user_ip', '$birthday', 'new', 'standard', NOW(), '$random_code')"; @mysql_query($sql) or die($config['error_26']);//error // get new user_id $sql = "SELECT user_id, email_address, random_code FROM member_profile WHERE random_code = '$random_code' AND email_address = '$email_address'"; $query = @mysql_query($sql); while ($result = @mysql_fetch_array($query)) $user_id = $result['user_id']; // set new user default privacy settings $sql = "INSERT INTO privacy (videocomments, profilecomments, privatemessage, friendsinvite, newsletter, user_id, publicfavorites, publicplaylists) VALUES ('yes', 'yes', 'yes', 'yes', 'yes', '$user_id', 'yes', 'yes')"; $query = @mysql_query($sql); @mysql_close(); // send email $email_template = 'email_templates/newmember.htm'; $subject = $config['email_welcome']; $to = $email_address; $from = $config['notifications_from_email']; //send email template to TBS for rendering of variable inside $template = $email_template; $TBS = new clsTinyButStrong; $TBS->NoErr = true; $TBS->LoadTemplate("$template"); $TBS->tbs_show(TBS_NOTHING); $message = $TBS->Source; //load postage.php define('access',true); include ('includes/postage.php'); // show success $notification_type = $config['notification_success']; $message = $config['registration_success']; $blk_notification = 0; $template = "themes/$user_theme/templates/main_1.htm"; $inner_template1 = "themes/$user_theme/templates/inner_notification.htm"; $TBS = new clsTinyButStrong; $TBS->NoErr = true; $TBS->LoadTemplate("$template"); $TBS->Render = TBS_OUTPUT; $TBS->Show(); @mysql_close(); die(); // else send confirmation email is off so we complete the regisration process and show sign in message } else { // insert new user record $sql = "INSERT into member_profile (email_address, user_name, password, passwordSalt, first_name, last_name, zip_code, country, birthday, account_status, account_type, date_created, random_code) VALUES ('$email_address', '$user_name', '$password', '$passwordSalt', '$first_name', '$last_name', '$zip_code', '$country_list', '$birthday', 'active', 'standard', NOW(), '$random_code')"; @mysql_query($sql) or die($config['error_26']);//error // get new user_id $sql = "SELECT user_id, email_address, random_code FROM member_profile WHERE random_code = '$random_code' AND email_address = '$email_address'"; $query = @mysql_query($sql); while ($result = @mysql_fetch_array($query)) $user_id = $result['user_id']; // set new user default privacy settings $sql = "INSERT INTO privacy (videocomments, profilecomments, privatemessage, friendsinvite, newsletter, user_id, publicfavorites, publicplaylists) VALUES ('yes', 'yes', 'yes', 'yes', 'yes', '$user_id', 'yes', 'yes')"; $query = @mysql_query($sql); @mysql_close(); $show_signup = 0; $show_login = 1; $show_action_msg = 1; $message_type = $config['notification_success']; $error_message = $config['reg_confirm_complete']; $action_msg = $message_type . " - " . $error_message; $template = "themes/$user_theme/templates/main_1.htm"; $inner_template1 = "themes/$user_theme/templates/inner_signup_form.htm"; $TBS = new clsTinyButStrong; $TBS->NoErr = true; $TBS->LoadTemplate("$template"); $TBS->Render = TBS_OUTPUT; $TBS->Show(); @mysql_close(); die(); } }// end captcha check if } ?>
  6. I've looked around the php script that I'm using and I can't figure out why my drop-down box border and background is blue when selected (see attached image). Can you help me with a suggestion on how to over-ride wherever that blue is? The css code I'm using to style the drop-down box is: input.common-input, select.dropdown_box { width:112px; height: 40px; padding: 4px 0px 0px 2px; margin: 0px; color:#cccccc; background: #ffffff; }
  7. Thanks for your reply. Much appreciated. Although I'm completely clear on what you're suggesting? I'm sure I can "hide the current border of the drop-down list, but I'm not completely clear on the rest of your suggestion. Would you mind providing an example using my code?
  8. I saw a website that had the drop-down menu in the search bar (on the right - where it shows "all Images" and a down arrow) - see SearchBar1 image attached. My current one on my web page looks like SearchBar2 image attached. I'm looking for guidance on how to change my code so that the drop-down menu looks more like SearchBar1 image. Any help will be appreciated. Here's my current code (which works successfully): <form method="get" action="../search.php" name="myForm" /> <select size="1" name="type" class="dropdown_box" /> <a href="#" class="dropdowmSubstitute" role="button"> <span class="textContainer"> <span class="dropdownText"> <option value="any string here">ALL</option> </span> </span> <span class="arrowContainer"> <span class="dropdownArrow">▼</span> </span> </a> <option value="1">Choice1</option> <option value="2">Choice2</option> </select> <input autocomplete="off" id="keyword" name="keyword" value="SEARCH WORDS" onfocus="if (this.value=='SEARCH WORDS') {this.value=''; this.style.color='#696969';}" onclick="clickclear(this, 'Search [var.site_name]')" onblur="clickrecall(this,'Search [var.site_name]')" value="" /> <input type="submit" value="VIEW"/> </form>
  9. I uploaded but didn't attach. Please find it attached. Thanks again emailcompose.txt
  10. Thanks again for your reply. I don't know how to find sender's email address value. I've attached the emailcompose php file (in txt form). Can you tell me if you can determine if that value is in there, please? Thanks
  11. Thanks for that reply. Much appreciated. However, I'm hoping I can get clarification on: I'm not sure what you mean there. And I understand this: but I don't know how to change $members_email to "the sender". Any additional assistance will be welcomed. Much thanks again.
  12. I'm using an existing php web site script where a user can turn on or off the ability to be notified (by email) if an internal message on the site has arrived into user's inbox. I'd like to modify the script so that the sender, of the internal message, be notified (by email), if the recipient has chosen not to be notified of internal messages. This is (part) the existing code: // check if receipients allow notifications is yes , send them a notification that they have an message if (notification_preferences($to_id, 'privatemessage') == true) { // send pm notification email to recipients registartion email addy $email_template = 'email_templates/newmessage.htm'; $subject = $config['email_new_email']; // at this point we do not have any email to send to $to = $members_email; $from = $config['notifications_from_email']; //send email template to TBS for rendering of variable inside $template = $email_template; $inner_template1 = "themes/$user_theme/templates/inner_email_compose.htm"; $TBS = new clsTinyButStrong; $TBS->NoErr = true; $TBS->LoadTemplate("$template"); $TBS->tbs_show(TBS_NOTHING); $message = $TBS->Source; //load postage.php include ('includes/postage.php'); $blk_notification = 1; $message_type = $config['word_success']; // Success $error_message = $config['error_25']; //25 == Request has been completed XXXXX=>success unset($_SESSION['update_token']); $_SESSION['update_token'] = ''; } If I replace the last } with } else { and then add the above code - modified - to notify the sender (by email) if the recipient has chosen not to be notified of internal messages. But I don't what to change in the code above, that would instruct it to } else { send something to the sender(of the internal message) email address. Can you help me with this part of my attempted modification? I've attached the entire code in txt (instead of php). Any help will be appreciated.
  13. In Chrome, and IE8, when this link is selected: <a href="../upload/[blk1.thumbnail]"><form action="../upload/[blk1.thumbnail]"><input type="image" src="../images/MI.png"></form></a> the file appears successfully. In IE10 and IE9, instead of the file appearing successfully, a dialog box appears asking "Do you want to open or save (the file name) from www...com? OPEN SAVE CANCEL In FF it says "You have chosen to open (the file name) which is application/ocet-stream from www...com OPEN SAVE CANCEL What can I add (or change) so that the file appears, upon selecting the link, in IE10, IE9 and FF? instead of a dialog box appearing?
  14. I am using the php web script and when I select a button/image with a link, I can proceed after clicking it, via Chrome, but nothing happens when I click it, when using IE10. Any ideas?
  15. I have tried other players and am now testing the mediaelement.js player, which works in all browsers, playing the video, and shows the 'poster' image in all browsers, except no 'poster' image appears in IE8. As I know the "poster' isn't supported by IE8, I'm looking for help with a work-around to place a thumbnail image as a substitute (for IE8) for the 'poster' image. Any help will be appreciated. Here's my current code: <video id="video" poster="http://www.-domain-.com/img/testImage.jpg" preload="none" controls="controls" width="240" height="220" > <source type="video/mp4" src="http://www.-domain-.com/video/testVideo.mp4"/> <object width="240" height="220" type="application/x-shockwave-flash" data="http://www.-domain-.com/mediaelement/flashmediaelement.swf"> <param name="movie" value="http://www.-domain-.com/mediaelement/flashmediaelement.swf" /> <param name="flashvars" value="controls=true&file=http://www.-domain-.com/video/testVideo.mp4" /> <!-- Image as a last resort --> <img src="http://www.-domain-.com/img/testImage.jpg" width="240" height="220" title="No video playback capabilities" /> </object> </video>
  16. I have video-js code on a web page like this: <video id="video2" class="video-js vjs-default-skin" controls preload="auto" width="140" height="120" poster="/video/countdown.jpg" data-setup="{}"> <source src="/video/vid1.mp4" type='video/mp4' /> </video> Do you see anything wrong with this code? I have that code several times on the same page. It all plays successfully in Chrome, but in IE11 while a few players play their video(self-hosted), I see this "The video player aborted due to corruption problem or because the video used features your browser did not support" And in Firefox 37.0, I see this: "A network error caused the video download to fail part-way". The code in the header is <link href="/video-js/video-js.css" rel="stylesheet"> <script src="/video-js/video.js"></script> <script>videojs.options.flash.swf = "/video-js/video-js.swf"</script> I suspect something simple in the code is a bit off. Do you know the solution? I look forward to any comments/insight/solutions.
  17. I'm using the PHP script for a video web site, and have added the ability to show the user's avatar (that he adds to his User Profile) as his uploaded video's Thumbnail image, in place of the thumbnail that's generated by the uploaded video itself (if the User leaves his avatar blank, the thumbnail generated by the video will show). It works successfully when the videos uploaded are short and not when the videos are longer. When I comment-out the added code (the nine commented-out lines near the bottom of the convertor.php code -posted below), all files upload successfully and the video-generated thumbnail appears. When I remove the commenting-out of those lines of code, only shorter videos show the avatar thumbnail, and only shorter videos(200KB for example) upload at all. Longer videos (25,000KB for example) don't appear to have uploaded. (maybe it's a timed-out thing when that code is looking for a thumbnail?) Any insight or suggestion will be appreciated. $sql = "SELECT file_name FROM pictures WHERE user_id = $user_id LIMIT 1"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $pic_file = $row['file_name']; $output_file = $base_path."/uploads/thumbs/".$file_name_no_extension.'.jpg'; $input_file = $base_path."/pictures/".$pic_file; echo "Input file = ".$input_file; echo " and Output file = ".$output_file."<br>"; copy($input_file, $output_file);
  18. Thanks for your reply. Any additional help will be appreciated.
  19. Thanks for your reply/code, however it did not work successfully. I'm using a PHP script where this Form ultimately uploads a video. It has been modified so that the user, while filling in the Form, can optional add an image file to his Form info, then upon selecting the Submit button the image is renamed and uploads the Form info and (optional) image, after Submit the next page is where the user selects a video file to upload (and the image is linked to the video). When the video is searched a link appears next to the video thumbnail image. The link is for viewing the (optional) image file. When am image file has not been uploaded via the Form, the link showed only "Access Forbidden", until the NoInfoAvailable1.png code was added (successfully)(to show something more informative than "Access Forbidden"). However, now using your new code provided in the posting, upon not uploading an image, via the Form, I now again see "Access Forbidden" instead of NoInfoAvailable1.png. Any additional help will be appreciated.
  20. Thank you for your reply. Regarding L8 "copies an image file already on the server and into the upload folder. This is so there is some image if the $_FILES upload process fail". Is it possible to SHOW the image already on the server, instead of creating a COPY of it each time "if the $_FILES upload process fail"?
  21. Thanks for your reply. Can you describe what's going on here, please?: if(!isset($error)){ $uploadedFile = $_FILES['file']['tmp_name']; $thumbnail = $_SESSION['user_id'] . '-' . $randomString . "." . $extension; move_uploaded_file($uploadedFile, "upload/" . $thumbnail); }else{ //Make sure NoInfo image has png extension $thumbnail = $_SESSION['user_id'] . '-' . $randomString . ".png"; copy("upload/NoInfoAvailable1.png", "upload/" . $thumbnail); } And here: Thanks
  22. Can you please explain ALL that this code does? if (isset($_POST['form_submitted'])): // $randomString needed regardless of passing tests so put outside error condition $randomString = time(); if((isset($_FILES) && $_FILES['file']['error'] != 0) || !isset($_FILES)){ //Unable to upload file to temp //Set variable for final move/copy condtion with no message $error = ''; }else{ $allowedExts = array("doc", "gif", "jpeg", "jpg", "txt", "pdf", "png", "txt"); $temp = explode(".", $_FILES['file']['name']); $extension = strtolower( end($temp) ); if(!in_array($extension,$allowedExts)){ $error = '<div id="errorMessage">>> Error: Invalid File Name </div>'; }elseif($_FILES['file']['size'] >= 100000){ $error = '<div class="errorMessage1">>> Error: Image File Size Exceeds Limit</div>'; } } if(!isset($error)){ $uploadedFile = $_FILES['file']['tmp_name']; $thumbnail = $_SESSION['user_id'] . '-' . $randomString . "." . $extension; move_uploaded_file($uploadedFile, "upload/" . $thumbnail); }else{ //Make sure NoInfo image has png extension $thumbnail = $_SESSION['user_id'] . '-' . $randomString . ".png"; copy("upload/NoInfoAvailable1.png", "upload/" . $thumbnail); } $_SESSION['thumbnail'] = $thumbnail; $file_location = '<a href="http://www....com/upload/' . $thumbnail . '">' . $thumbnail . '</a>'; endif; if(isset($error)){echo $error;} Thank you. I look forward to being enlightened.
  23. I have this code, for an Upload Form, that works successfully renaming and moving an uploaded file to the upload/ folder. If an image isn't uploaded, what code can I add to put a default file where the file would have been if it were uploaded? This code is what's working currently: if ($form_submitted == 'yes') { $allowedExts = array("gif", "jpeg", "jpg", "txt", "rtf", "png"); $temp = explode(".", $_FILES["file"]["name"]); $extension = strtolower( end($temp) ); if (!in_array($extension,$allowedExts) && $_FILES["file"]["name"] != "" ) { echo ("<div id=\"errorMessage\"> >> Error: Invalid File Name </div>"); } else if ($_FILES["file"]["size"] >= 100000) { echo ("<div class=\"errorMessage1\"> >> Error: Image File Size Exceeds Limit </div>"); } $length = 20; $randomString = (time()); $thumbnail = $_SESSION['user_id'] . '-' . $randomString . "." . $extension; move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $thumbnail); $_SESSION['thumbnail'] = $thumbnail; $file_location = '<a href="http://www....com/upload/' . $thumbnail . '">' . $thumbnail . '</a>'; } This is my attempt to "put a default file where the file would have been if it were uploaded", but my additions didn't suceed: if ($form_submitted == 'yes') { $defaultFilePath = '../upload/Default.png'; // set this. $allowedExts = array("gif", "jpeg", "jpg", "txt", "rtf", "png"); $temp = explode(".", $_FILES["file"]["name"]); $extension = strtolower( end($temp) ); if (!in_array($extension,$allowedExts) && $_FILES["file"]["name"] != "" ) { echo ("<div id=\"errorMessage\"> >> Error: Invalid File Name </div>"); $source = $defaultFilePath; } else if ($_FILES["file"]["size"] >= 100000) { echo ("<div class=\"errorMessage1\"> >> Error: Image File Size Exceeds Limit </div>"); $source = $_FILES["file"]["tmp_name"]; } $length = 20; $randomString = (time()); $thumbnail = $_SESSION['user_id'] . '-' . $randomString . "." . $extension; if ($source === $defaultFilePath) { copy($source, "upload/" . $thumbnail); } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $thumbnail); } $_SESSION['thumbnail'] = $thumbnail; $file_location = '<a href="http://www...com/upload/' . $thumbnail . '">' . $thumbnail . '</a>'; } Any help with getting this to work correctly will be appreciated.
×
×
  • 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.