Page 1 of 5 123 ... LastLast
Results 1 to 10 of 49

Thread: FTP video upload from form

  1. #1
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default FTP (again)

    I know your all getting sick of my FTP questions. . . I'm sick of askin' 'em. But my script isn't working. . . It creates the file, but puts no information in it (file size is always 0 bytes). Any help would be great.

    Code:
    if ($_POST['Submit'] == 'Submit'){
    	$conn_id = ftp_connect("localhost") or die("Couldn't connect");
    	$login_result = ftp_login($conn_id, "????", "??????") or die("ERROR IN FTP CONNECTION");
    	
    	@ftp_mkdir($conn_id, './Information/Uploads/');
    	
    		$path2  = './Uploads/';
    		$path = './Information/Uploads/';
    
    	$o_name = basename($_FILES['uploadedfile']['name']);
    	$path .= $o_name;
    	$path2 .= $o_name;
    
    	$temp = tmpfile();
    	
    	if(ftp_fput($conn_id, $path, $temp, FTP_ASCII)){
    		print '<h1>File "'.$o_name.'" has been uploaded.</h1><h2>We thank you for your donation to this website, and look forward to seeing it accessed by our users.</h2>';
    
    	
    			$path_parts = pathinfo($path);	
    		$title 		= $_POST['title'];
    		$filetype 	= $path_parts['extension'];
    		$style 		= $_POST['style'];
    		$disc		= $_POST['discription'];
    		$sugrank 	= $_POST['suggestedrank'];
    		$provider	= $_SESSION['username'];
    		$notes		= $_POST['notes'];
    		$copyright	= $_POST['copyright'];
    		
    		MySQL_Query("INSERT INTO files VALUES(
    			NULL,
    			'$path2',
    			'$title',
    			'$filetype',
    			'$style',
    			'$disc',
    			'$sugrank',
    			'$provider',
    			'$notes',
    			'$copyright'
    		)");
    	} else {
    		print "Error Uploading File:<br>$o_name";
    	}
    	MySQL_Close($Connection);
    	ftp_close($conn_id);
    }
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  2. #2
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    Or I will take an alternate script if that is easier for you guys. . . Either way. . .
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  3. #3
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    I don't see any function to put in the file contents.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  4. #4
    Join Date
    Jul 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    After quickly scanning your code I decided to see wat php.net says about using "ftp_fput"
    here is the link to that page
    http://www.php.net/manual/ro/function.ftp-fput.php

    there is an example on it:
    PHP Code:
    <?php

    // open some file for reading
    $file 'somefile.txt';
    $fp fopen($file'r');

    // set up basic connection
    $conn_id ftp_connect($ftp_server);

    // login with username and password
    $login_result ftp_login($conn_id$ftp_user_name$ftp_user_pass);

    // try to upload $file
    if (ftp_fput($conn_id$file$fpFTP_ASCII)) {
        echo 
    "Successfully uploaded $file\n";
    } else {
        echo 
    "There was a problem while uploading $file\n";
    }

    // close the connection and the file handler
    ftp_close($conn_id);
    fclose($fp);

    ?>
    the main difference i see here is that the code above uses fopen and yours does not. you are using tmpfile which to me looks like it only makes a temporary file (which when created will be blank). So My GUESS is that instead of tmpfile() you should be using fopen on that line and opening the file you are trying to use. again, that is just a guess.

  5. #5
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Try this it should work, it also gives you numbers on the side to and two save buttons and refresh just in case something goes wrongs....

    Code:
    <?php
    $loadcontent = "YUOR FILE HERE!!!!.html"; 
        if($save_file) { 
            $savecontent = stripslashes($savecontent); 
            $fp = @fopen($loadcontent, "w"); 
            if ($fp) { 
                fwrite($fp, $savecontent); 
                fclose($fp);
    print '<a href='.$_SERVER[PHP_SELF].'>Refresh</a>'; 
    print "<html><head><META http-equiv=\"refresh\" content=\"0;URL=$_SERVER[PHP_SELF]\"></head><body>"; 
     
    } 
    } 
        $fp = @fopen($loadcontent, "r"); 
            $loadcontent = fread($fp, filesize($loadcontent)); 
    $lines = explode("\n", $loadcontent);
    $count = count($lines);
            $loadcontent = htmlspecialchars($loadcontent); 
            fclose($fp); 
    for ($a = 1; $a < $count+1; $a++) {
    $line .= "$a\n";
    }
    ?> 
    <form method=post action="<?=$_SERVER[PHP_SELF]?>"> 
    <input type="submit" name="save_file" value="Save">    
    <table width="100%" valign="top" border="0" cellspacing="1" cellpadding="1">
      <tr>
        <td width="3%" align="right" valign="top"><pre style="text-align: right; padding: 4px; overflow: auto; border: 0px groove; font-size: 12px" name="lines" cols="4" rows="<?=$count+3;?>"><?=$line;?></pre></td>
        <td width="97%" align="left" valign="top"><textarea style="text-align: left; padding: 0px; overflow: auto; border: 3px groove; font-size: 12px" name="savecontent" cols="150" rows="<?=$count;?>" wrap="OFF"><?=$loadcontent?></textarea></td>
      </tr>
    </table>
     
    <br> 
    <input type="submit" name="save_file" value="Save">    
    </form>
    I recommend not to use php if your letting other people use this, saftey reasons.. and hacking..
    Hey new design new look, goto xudas for personal webdsign help.. (:

  6. #6
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    ???? I'm confused
    Sorry guys, but I thought I know more about FTP-- evidently not, lol. Can I get a bit more info on what's going on with your script isanemonkey ?
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  7. #7
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    sorry... my script is like yours but it right now only edits the information and saves it..

    I am currently working on how to upload, and make a new page and edit there and now..

    but as of now this is what I am using for every page that i want

    i don't know if this is what you are looking for but I have it up so you can test it out...

    http://www.xudas.com/test/index.html
    http://www.xudas.com/test/edit.php

    goto index to see before look then goto edit and write something(html only) and save then goto the index.html page and see...

    but any questions let me know...

    oh and your site sweet n treats its pretty good.. the layout is kinda good. but not eye catching.... but AWESOME!!!
    Hey new design new look, goto xudas for personal webdsign help.. (:

  8. #8
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    I don't think that is what I am looking for

    I need a way to let users upload a file to the server, such as jpg's and mpeg's and pdf's and what-not. Any ideas? Can I fix the script at the start of this thread?

    Quote Originally Posted by tech_support View Post
    I don't see any function to put in the file contents.
    What do I do to insert the contents into the file?

    Quote Originally Posted by insanemonkey View Post
    oh and your site sweet n treats its pretty good.. the layout is kinda good. but not eye catching.... but AWESOME!!!
    Thanks for the input. Any suggestions? The owners wanted it "simple," so I am at a loss (The original draft was better, but they didn't like it ). (The other website that I am working on now--my website--is really starting to pop )
    Last edited by Jas; 10-02-2007 at 07:11 PM.
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  9. #9
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    so your looking for a script that will just upload images or what not... why didnt you say that.. you don't use fopen and script like that for uploading...

    welll here is a upload script... I like this one the most since it tells the person the link of the file is at....

    PHP Code:
    <?php

      error_reporting
    (E_ALL E_NOTICE); // Show all major errors.

      // Check to see if the button has been pressed
      
    if (!empty($_REQUEST['sendForm']))
      {
        
    // Assign the name to a variable
        
    $name $_FILES['uploaded_file']['name'];
        
    // Assign the tmp_name to a variable
        
    $tmp_name $_FILES['uploaded_file']['tmp_name'];
        
    // Assign the error to a variable
        
    $error $_FILES['uploaded_file']['error'];
        
    // Assign the size to a variable
        
    $size $_FILES['uploaded_file']['size'];
        
    // No trailing slash
        
    $uploadFilesTo 'LOCATION TO YOUR UPLOADED FILES';
        
    // Create safe filename
        
    $name ereg_replace('[^A-Za-z0-9.]''-'$name);
        
    // Disallowed file extensions
        //what files you don't want upoad... leave this alone and you should be fine but you could add more
        
    $naughtyFileExtension = array("php""php3""asp""inc""txt""wma""mov""js""exe""jsp""map""obj"" """"html""mp3""mpu""wav""cur""ani");    // Returns an array that includes the extension
        
    $fileInfo pathinfo($name);
        
    // Check extension
        
    if (!in_array($fileInfo['extension'], $naughtyFileExtension))
        {
          
    // Get filename
          
    $name getNonExistingFilename($uploadFilesTo$name);
          
    // Upload the file
          
    if (move_uploaded_file($tmp_name$uploadFilesTo.'/'.$name))
          {
              
    // Show success message
              
    echo '<center><p>File uploaded to http://www.yoursite.com/'.$uploadFilesTo.'/'.$name.'</p></center>';
          }
          else
          {
              
    // Show failure message
              
    echo '<center><p>File failed to upload to /'.$name.'</p></center>';
          }
        }
        else
        {
            
    // Bad File type
            
    echo '<center><p>The file uses an extension we don\'t allow.</p></center>';
        }
      }
     
      
    // Functions do not need to be inline with the rest of the code
      
    function getNonExistingFilename($uploadFilesTo$name)
      {
          if (!
    file_exists($uploadFilesTo '/' $name))
              return 
    $name;
         
          return 
    getNonExistingFilename($uploadFilesTorand(100200) . '_' $name);
      }
    ?>
    <table bgcolor="gray" border="1"><tr>
    <tr><td>
    <br>

    <form action="" method="post"    enctype="multipart/form-data">
      <input type="file" name="uploaded_file"><br>
      <input type="submit" name="sendForm" value="Upload Image">
    </form>

    </td></tr>
    </table>
    now just fool around with the script.... but you have to edit some of the things though.. any question let me know
    Hey new design new look, goto xudas for personal webdsign help.. (:

  10. #10
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    That is well commented, but, um, it also has to be for videos. . . which would require FTP (That's not FTP, is it?).
    I do thank you for the script though. There are several parts that I can use, like blocking file types and fixing the filenames (which I never thought of).
    Last edited by Jas; 10-07-2007 at 07:16 PM.
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •