Jump to content

Chrisj

Members
  • Posts

    551
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Chrisj

  1. Thanks for your message.

    I opened the web page where the "select "Click Here" link is" and then opened "the tab 'Network' in Google Chromes' Developer tools",

    and didn't see the line "Header set Content-Disposition attachment" anywhere.

     

    My .htaccess file looks like this:

    # By default, no module files may be accessed
    # directly from a webbrowser.
    Order deny,allow
    Deny from all
    
    # File types for which we make an exception.
    <Files ~ "\.(gif|jpg|jpeg|png|css|doc|js|php)$">
        Order allow,deny
        Allow from all
    </Files>
    
    Header set Content-Disposition attachment
    
    ErrorDocument 403 /403.php
    ErrorDocument 404 /404.php
    
    AddType application/x-httpd-php .html .htm
    

    Any additional help will be appreciated.

  2. Thanks for your reply.

    If I read your reply correctly, this is what I tried, I added this line "Header set Content-Disposition attachment" into a .htaccess file, and then added the .htaccess file to the /upload/ folder, then uploaded a .doc file, but it still downloaded.

    If I didn't do that correctly please let me know what to do. If I did that correctly, any other ideas will be appreciated.

  3. This upload form code works successfully, where a file is chosen, renamed and stored in the 'upload' folder,
    and when I select the "Click Here" link from a web page, it shows what was uploaded, successfully.
     
    But when I added the extension "doc" and selected "Click Here", instead of showing the document, 
    the file automatically shows that it's downloading to my computer. Can you tell me possibly why is that happening?
     
    $allowedExts = array("gif", "jpeg", "jpg", "pdf", "doc", "png");
    $temp = explode(".", $_FILES["file"]["name"]);
    $extension = strtolower( end($temp) );
    if (!in_array($extension,$allowedExts))
    {
    echo ("Error - Invalid File Name");
    exit();  
    }
    $length = 20;
    $randomString = (time());
    $thumbnail = $randomString . "." . $extension;
    move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $thumbnail);
    $sql = "INSERT INTO videos ( filename ) VALUES( '$thumbnail' )";
    mysql_query($sql);
    $file_location = '<a href="http://www....com/upload/' . $thumbnail . '">' . $thumbnail . '</a>';
    

     

  4. In the PHP script I'm using, in the Upload Form the user selects an image to Upload, the Form renames it like so:

    $allowedExts = array("gif", "jpeg", "jpg", "pdf", "png");
    $temp = explode(".", $_FILES["file"]["name"]);
    $extension = strtolower( end($temp) );
    
    if (!in_array($extension,$allowedExts))
    {
    echo ("Error - Invalid File Name");
    
    }
    $length = 20;
    $randomString = (time());
    $thumbnail = $randomString . "." . $extension;
    
    

    The random string works successfully, but I'd like to add the user_id to the beginning of it and a dash, like this:

    user_id - 

    So, the new file name would be something like:   user_id-randomString.extension

     

    Can you please help me add that?

     

  5. Thanks for your reply, but I'm not sure if providing the source is going to help here. It isn't my script I'm just trying to tweak it, to get this one function working.

     

    But, what I actually think might help, please, is to know if I add in a function, into the code above, like this example:

     function getFilename($id) {
     $sql1 ="SELECT filename FROM videos WHERE indexer = '".$id."'";
     $query1 = mysql_query($sql1) or DIE(mysql_error());
     $result = mysql_fetch_array($query1);
    
     return $result['filename'];
    
    }
    

    Will it correspond with this upload Form code - where the image file is chosen and stored:

    $allowedExts = array("gif", "jpeg", "jpg", "pdf", "png");
    $temp = explode(".", $_FILES["file"]["name"]);
    $extension = strtolower( end($temp) );
    if (!in_array($extension,$allowedExts))
    {
    echo ("Error - Invalid File Name");
    }
    $length = 20;
    $newfilename = $_SESSION['user_id'].$_FILES["file"]["name"];
    $thumbnail = $newfilename;
    move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $thumbnail);
    
    $sql = "INSERT INTO videos ( filename ) VALUES( '$thumbnail' )";
    
    mysql_query($sql);
    $file_location = '<a href="http://www.--.com/upload/' . $thumbnail . '">' . $thumbnail . '</a>';
    

    Any additional help will be greatly appreciated.

  6. Thanks for your replies.

    When I add your "standard HTML img element" 

    <?php
    $file = '/home/me/www/images/' . $row['filename'];
    if(file_exists($file)) {
     $file = $row['filename'];
    } else {
     $file = 'default.jpg';
    }
     echo '<img src="http://mysite.com/images/' . $file . '" alt="No image" />';
     ?>
    

    I see this part of that code on the page   '; ?>

    Help please.

  7. I'm using a templated PHP script where the (video) Upload Form info (title, description, etc.) is displayed (after the upload) on a page below the video.
     
    I added a basic image-uploader to the Form, and some code that, via the Form, adds the 'user_id' to the beginning of the file name, for example, people.png uploaded (by user 9) becomes the new file name: 9people.png, which gets uploaded into the /upload/ folder, and stores that new file name into a db table called 'videos', into a column named 'thumbnail'. 
     
    I'm looking for guidance with making a successful hyperlink(to the image) appear where the Upload Form info is displayed.
     

    This is the results.php page code that corresponds with the html page (inner_results.htm):

    <?php
    include_once ('classes/config.php');
    include_once ('classes/sessions.php');
    include_once ('classes/functions.inc.php');
     $page_title        = $site_name;
     $submitted         = $_POST['submitted'];
    $which_one         = mysql_real_escape_string($_GET['load']);
    $limit         = 20;
     $keyword = $_SESSION['searched'];
     // this is per each template from config.inc.php advanced config settings
    $page_display_small_width    = $config['general_medium_thumb_width']; // 80
     $member_credits = get_member_credits($user_id);
     if ($user_id != "") {
     $inner_template1     = "themes/$user_theme/templates/inner_results.htm";
     }else{
     $show_login        = 1;
    $inner_template1 = "themes/$user_theme/templates/inner_signup_form.htm";
    }
     // FUNCTIONS
     function getUsername($id) {
     $sql1 = "SELECT * FROM member_profile WHERE $query1 = mysql_query($sql1) or DIE(mysql_error());
    $result = mysql_fetch_array($query1);
     return $result['user_name'];
    }
    function getVidTitle($id) {
    $sql1 = "SELECT * FROM videos WHERE indexer = $id";
    $query1 = mysql_query($sql1) or DIE(mysql_error());
    $result = mysql_fetch_array($query1);
     return $result['title'];
    }
    ?>
    Can you make a suggestion, or give me an idea, as to what I might add to results.php (and inner_results.php) in order to display a successful hyperlink to the image that was uploaded with the video? 
    Any help will be appreciated.
     
  8. I'm using a templated PHP script and have successfully added a link (to an image) 
    to an html page there  (inner_play.htm) 
    <a href="http://www.--.com/upload/[var.thumbnail]"><?php echo $newfilename?>Click Link</a>
    

    and this (into the play.php file):

    $thumbnail = $result['thumbnail'];
    

    and this

    $thumbnail = $_SESSION['$newfilename'];
    
    So, I added it to another page (search_results.htm) without success.
     
    I've tried a few different places, (in search.php file), to add:
    $thumbnail = $result['thumbnail'];
    $thumbnail = $_SESSION['$newfilename'];
    but the link doesn't work from search_results.htm page
    Maybe you can simply tell me where those lines should work best in search.php, or any other insight.
    Any help will be appreciated. - see Search.php file attached

    search.php

  9. Trying again:

    <?php
    
    
    include_once ('classes/config.php');
    include_once ('classes/sessions.php');
    include 'uploader_conlib.php';
    
    $config['notification_error'] = $lang_error;
    
    $page_title = $lang_upload_video;
    
    
    if ($_SESSION['user_id'] == "") {
    	header("Location: " . "$base_url/login.php");
    	die();
    }
    
    $load_javascript	= 1;
    $ahah			= 1;
    $thickbox = 1;
    
    ///////////////////////////////////////////////////////////////////////////////////////
    // ADDED SPAMMER UPLOAD TRACKING LOGING
    //
    
    $member_uploading		= $_SESSION['user_name'];
    $tracking_log_file	= 'logs/uploader_log.txt';
    $admin_email		= $config['admin_notify_email'];
    $user_ip			= mysql_escape_string($_SERVER['REMOTE_ADDR']);
    $referer			= mysql_real_escape_string($_SERVER['HTTP_REFERER']);
    
    if ( $referer == '' ) die_spammer_alerts();
    if ( !ereg ($_SERVER['SERVER_NAME'], $referer) ) die_spammer_alerts();
    
    ///////////////////////////////////////////////////////////////////////////////////////
    
    //echo $debugmodex;
    
    //get channel data, create "select" form fields to load into form
    $sql			= "SELECT channel_id, channel_name FROM channels";
    $result1 		= @mysql_query($sql);
    $count_cats 	= @mysql_num_rows($result1);
    $fields_all 	= '';
    $sub_fields_all	= '';
    $show_fields	= '';
    
    $fields_all .= '<option value="99999">Select One</option>';
    
    while ($result = @mysql_fetch_array($result1)) {
        	$fields_all .= '<option value="'.$result['channel_id'].'">'.$result['channel_name'].'</option>';
    }
    
    $sub_cat_choice = (int) mysql_real_escape_string( $_GET['sub_cat'] );
    
    if ( $sub_cat_choice ) {
    
    	if ( $sub_cat_choice == '99999' ) {
    
    		$sub_fields_all  .= '<select class="image_form" style="width:160px;" size="1" name="sub_cat">';
    		$sub_fields_all  .= '<option value="99999">'.$lang_no_sub_categories.'</option>';
    		$sub_fields_all .= '</select> ('.$lang_select.')';
    		echo $sub_fields_all;
    		die();
    
    	} else {
    
    		$sql2			= "SELECT * from sub_channels WHERE parent_channel_id = $sub_cat_choice";
          	$query		= @mysql_query($sql2);
    		$sub_fields_all  .= '<select class="image_form" style="width:160px;" size="1" name="sub_cat">';
    
          	while ($result2 = @mysql_fetch_array($query)) {
        			$count_subs		= @mysql_num_rows($query);
        			$sub_fields_all  .= '<option value="'.$result2['sub_channel_id'].'">'.$result2['sub_channel_name'].'</option>';
         		}
    
         		if ( $count_subs == '' ) {
         			$sub_fields_all  .= '<option value="99999">'.$lang_no_sub_categories.'</option>';
    		}
    
         		$sub_fields_all .= '</select> ('.$lang_select.')';
    
         		echo $sub_fields_all;
    	     	die();
    	}
    }
    
    // grab values from form if any
    $form_submitted		= $_POST['form_submitted'];
    $title 			= $_POST['title'];
    $description 		= $_POST['description'];
    $tags 			= $_POST['tags'];
    $thumbnail    = $_POST['thumbnail'];
    $location_recorded	= $_POST['location_recorded'];
    $allow_comments 		= $_POST['allow_comments'];
    $allow_embedding 		= $_POST['allow_embedding'];
    $public_private 		= $_POST['public_private'];
    $channel 			= $_POST['channel'];
    $sub_cat			= $_POST['sub_cat'];
    $procede 			= true;
    
    ///////////////////////////////////////
    /////////////////////////////////////////
    
    $allowedExts = array("gif", "jpeg", "jpg", "pdf", "png");
    $temp = explode(".", $_FILES["file"]["name"]);
    $extension = strtolower( end($temp) );
    //  ADD CHECK FOR VALID FILE
    if (!in_array($extension,$allowedExts))
    {
    echo ("Error - Invalid File Name");
    //exit();  // or do whatever else you want here
    }
    $length = 20;
    $newfilename = $_SESSION['user_id'].$_FILES["file"]["name"];
    //
    $thumbnail = $newfilename;
    //
    move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $thumbnail);
    //
    $sql = "INSERT INTO videos ( filename ) VALUES( '$thumbnail' )";
    //
    mysql_query($sql);
    $file_location = '<a href="http://www.--.com/upload/' . $thumbnail . '">' . $thumbnail . '</a>';
    
    ///////////////////////////////////////
    /////////////////////////////////////////
    
    $row = mysql_query("SELECT channel_name FROM channels WHERE channel_id = '$channel'");
    
    while( $result = mysql_fetch_assoc($row) ) $channel_name = $result['channel_name'];
    
    // validate form
    if ($form_submitted == 'yes') {
    
    	if ($_SESSION['user_id'] == '') die();
    	$post_vid_upload_token	= mysql_real_escape_string( $_POST['vid_upload_token'] );
    
    	if ( $post_vid_upload_token != $_SESSION['vid_upload_token'] ) die();
    
    	foreach ($_POST as $key => $value) {
          	if ($key == 'title' || $key == 'description' || $key == 'tags' || $key == '$channel') {
                	if (!isset($value) || ($value == '')) {
                    		$display_key	= @str_replace('_', ' ', $key);
                    		$error_message	= $config['notification_error'];
                    		$blk_notification = 1;
                    		$error_message 	= $error_message . " - " . $display_key . "  - $lang_required ";
                    		$procede 		= false;
                	}
            	}
        	}
    
        	if ( $channel == '99999' ) {
    
        		$error_message	= $config['notification_error'];
         		$blk_notification = 1;
         		$error_message 	= $error_message . " - $lang_select_channel";
        		$procede 		= false;
        	}
    } else {
    
    	$procede = false;
    }
    
    // display page with form error
    if ($procede == false && $form_submitted == 'yes') {
    	$template 		= "themes/$user_theme/templates/main_1.htm";
        	$inner_template1 	= "themes/$user_theme/templates/inner_upload_video_form.htm";
        	$TBS 			= new clsTinyButStrong;
        	$TBS->NoErr 	= true;
        	$TBS->LoadTemplate("$template");
        	$TBS->Render 	= TBS_OUTPUT;
        	$TBS->Show();
    	@mysql_close();
        	die();
    }
    
    // disply clean page
    if (!isset($form_submitted) || ($form_submitted == "")) {
    	$template 		= "themes/$user_theme/templates/main_1.htm";
        	$inner_template1 	= "themes/$user_theme/templates/inner_upload_video_form.htm";
        	$TBS 			= new clsTinyButStrong;
        	$TBS->NoErr 	= true;
        	$TBS->LoadTemplate("$template");
        	$TBS->Render 	= TBS_OUTPUT;
        	$TBS->Show();
        	@mysql_close();
        	die();
    }
    
    if ($procede == true && $form_submitted == 'yes') {
        if ($_SESSION['user_id'] == "") die();
    
        //=================================START OF UPLOAD=================================
        $THIS_VERSION = '2.0';
        if (isset($_GET['cmd']) && $_GET['cmd'] == 'about') {
            kak("<u><b>UBER UPLOADER FILE UPLOAD</b></u><br>UBER UPLOADER VERSION =  <b>" .
                $UBER_VERSION . "</b><br>UU_FILE_UPLOAD = <b>" . $THIS_VERSION . "<b><br>\n");
        }
        $tmp_sid = md5(uniqid(mt_rand(), true));
        ///////////////////////////////////////////////////////////////////////
        // This is where you might set your config file eg.                  //
        // if($_SESSION['user'] == "tom"){ $config_file = 'uu_tom_config'; } //
        ///////////////////////////////////////////////////////////////////////
        $config_file = $default_config_file;
        $path_to_upload_script .= '?tmp_sid=' . $tmp_sid;
        $path_to_ini_status_script .= '?tmp_sid=' . $tmp_sid;
    
        if ($MULTI_CONFIGS_ENABLED) {
            $path_to_upload_script .= "&config_file=$config_file";
            $path_to_ini_status_script .= "&config_file=$config_file";
        }
    
        //allow form to be refilled on error
        foreach($_POST as $key=>$value) {
             $$key = $value;
        }
    
        $template = "themes/$user_theme/templates/main_1.htm";
        $inner_template1 = "themes/$user_theme/templates/inner_upload_video.htm";
        $TBS = new clsTinyButStrong;
        $TBS->NoErr = true;// no more error message displayed.
        $TBS->LoadTemplate("$template");
        $TBS->Render = TBS_OUTPUT;
        $TBS->Show();
    
        @mysql_close();
        die();
        //===============================================================END OF UPLOADER================================================================
    }
    
    function die_spammer_alerts() {
    
    global $member_uploading, $user_ip, $admin_email, $site_name;
    
    	$subject	= 'Possible Video Spamming !!';
    
    	$message	= "The following member uploaded a possible spam video: => " . $member_uploading . "\n\n" . "The IP used: " . $user_ip . "\n";
    
    	$to		= $admin_email;
          $from 	= $site_name;
    
          mail($to, $subject, $message, "From: $from");
    
          // if config auto ban spammer is true - enter user name and ip to ban table
          /*
          include_once ('classes/config.php');
          $sql		= "DELETE FROM videos WHERE video_id = '$raw_video'";
          $query	= @mysql_query($sql);
          */
    
          write_log($message);
    }
    
    function write_log($message) {
    	global $tracking_log_file;
    
    	if (@file_exists($tracking_log_file)) {
        		$fo = @fopen($tracking_log_file, 'a');
            	@fwrite($fo, $message);
            	@fclose($fo);
    
        	} else {
          	$fo = @fopen($tracking_log_file, 'w');
            	@fwrite($fo, $message);
            	@fclose($fo);
        	}
    exit();
    }
    
    
    ?>
    
  10. Thanks ginerjm for that. Much appreciated. Very helpful.

     

    Another question, please; Currently, the user id populates the Thumbnail field, of the Upload Form, upon the Form page opening.

    And after Submit, the (uploaded) file name is added to the user_id, in that field. 

     

    How can I change it so the user_id doesn't populate the Thumbnail field upon opening the Form page, but is added to the (uploaded) file name,

    after Submit?

     

    Any help will be appreciated

  11. Can you please tell me what each of these lines of code means?

    $allowedExts = array("gif", "jpeg", "jpg", "png");
    $temp = explode(".", $_FILES["file"]["name"]);
    $extension = strtolower( end($temp) );
    $length = 20;
    $newfilename = $_SESSION['user_id'].$_FILES["file"]["name"];
    $thumbnail = $newfilename . "." . $extension;
    move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $thumbnail);
    $sql = "INSERT INTO videos ( filename ) VALUES( $thumbnail )";
    mysql_query($sql);
    $file_location = '<a href="http://www.--.com/upload/' . $thumbnail . '">' . $thumbnail . '</a>';
    $description = $description . " \n " . $newfilename;
    
  12. In an Upload Form that I'm using, it has this line:

    $newfilename = $SESSION['userid'].$_FILES["file"]["name"];
    

    I need to "store the newfilename in a session variable" (in another php file)

    and use the session variable in this link, instead of newfilename:

    <a href="upload/<?php echo $newfilename?>"><?php echo $newfilename?></a>

    So, would this be correct?

    $newfilename = $_SESSION['newfilename'].$_FILES["newfilename"];
    
  13. This change now gets the image uploaded, however this code takes me to the next page.

    I'd like to figure out how to stay on the same page after upload. Any help will be appreciated.

    <form enctype="multipart/form-data" action="" method="POST">
    <input type="file" name="file" id="file">
    <input class="upload-input" type="hidden" name="form_submitted" value="yes" />
    <input type="submit" value="submit" />
    </form>
    
  14. I don't know why this image upload code isn't uploading the image file to the uploads/ folder.

    Any help will be appreciated.

    	$allowedExts = array("gif", "jpeg", "jpg", "png");
    	$temp = explode(".", $_FILES["file"]["name"]);
    	$extension = strtolower( end($temp) );
    	if (  $_FILES["file"]["size"] < 2000000
    	&& in_array($extension, $allowedExts) )
    	{
    	if ($_FILES["file"]["error"]!= 0)
    	{
    	echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
    	} else {
    	$length = 20;
    	$randomString = substr(str_shuffle(md5(time())),0,$length);
    	$newfilename = $randomString . "." . $extension;
    	move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $newfilename );
    	$file_location = '<a href="http://www.--.com/upload/' . $newfilename . '">http://www.--.com/upload/' . $newfilename . '</a>';
    	}
    	} else {
    	echo "Invalid upload file";
    	}
    
    <form enctype="multipart/form-data" action="uploader.php">
    <input type="file" name="file" id="file">
    <input type="submit" name="submitted" value="Submit">
    </form>
    
×
×
  • 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.