Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
  1. #1
    Junior Member
    Join Date
    Apr 2004
    Location
    Australia
    Posts
    1
    Member #
    5556
    I was wondering if thers a code for a Ftp Upload that sends the selected file to my server without any prompts.

    what I mean is - A Small Edit/Text Box to type directory file in manaully, and a button to "Browse" for it, once selected, hit Upload button and it automatically uploads the selected file onto the server. It would need to have a place to enter in login and password in the code, so that the user did not need to.

    Then if possible, once upload is complete, perhaps a link to it could display it self, and also whether the upload completed or not.

    If anyone could help me out, that would be great.

    If this cant be done in Html or Java, but can be done in Php which I know can be done, and you know php code for it, please tell me that as i can use it aswell.

    If you think this is to much work for nothing, please feel free to contact me at dontspillthebeer@hotmail.com and I'll arrange something.

    Thanks

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Ugh... I read about 2 lines of your post before I couldn't stand the bold face any longer. I suggest that if you still require assistance with this, you remove the bold face so that we can read it.

  4. #3
    Senior Member teal's Avatar
    Join Date
    Dec 2003
    Posts
    247
    Member #
    4319
    Sorry transio, I will help and it doesn't bug me a bit

    First off, in HTML:

    Code:
    <form action="uploadfile.php" method="post" enctype="multipart/form-data" class="content">
    	<p>Password: 
    	  <input type="password" name="password">
    <!-- Password is advisory, not nessecary -->
    	</p>
    	<p>Enter File Name:  
        <input type="file" name="filetobeuploaded"></p>
        <input type="submit" value="Upload all information"> 
        <input type="reset" value="Reset">
    Then, in your uploadfile.php:
    PHP Code:
    print "<h1>Your data is being processed &nbsp;Joy!</h1><h1> . . . </h1><br>";
    if (
    strtolower ($password) === strtolower (password))
    {
        if (
    $filetobeuploaded == FALSE)
        {    
            print 
    "You did not mark a file for upload.<br>";
        }
        else
        {
        if (
    $HTTP_POST_FILES['filetobeuploaded']['size'] <= 0)
            {
                print 
    "<h4>Your file failed to upload!</h4><br>";
                print 
    "The file size was larger than 2 MB.<br>";
                print 
    "Please reduce it to a reasonable size and resent.<br>";
            }
            else
            {
                
    copy($HTTP_POST_FILES['filetobeuploaded']['tmp_name'],
                    
    $HTTP_POST_FILES['filetobeuploaded']['name']);
                print 
    "<h4>Thanks for helping us out and submitting a file!</h4><BR>";
                print 
    "<h4>Your file has been stored on our system.<BR>";
            }
        } 
    /*Edit: Whoopse, forgot one curly bracket here!*/ 
    /*There we go!*/ 
    This is copied straight from an uploader I made, which works perfectly.

    Edit- This copies the file to the same directory as you save this file into.
    Whoth steps forth to mock the teal? Whom couldst say a color superior!

    Proclamith me, it cannot be done.

  5. #4
    Senior Member teal's Avatar
    Join Date
    Dec 2003
    Posts
    247
    Member #
    4319
    I guess I'm not getting paid
    Whoth steps forth to mock the teal? Whom couldst say a color superior!

    Proclamith me, it cannot be done.

  6. #5
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Awarded as per the rules.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  7. #6
    Junior Member ozxar's Avatar
    Join Date
    Jan 2004
    Posts
    3
    Member #
    4719
    could someone tell me how to do the PHP page thing, i haven't done any coding in PHP

  8. #7
    Senior Member Fallout's Avatar
    Join Date
    Aug 2003
    Location
    Richmond, Virginia
    Posts
    543
    Member #
    2748
    Just copy what teal has written in the code box and save it as uploadfile.php. Then upload this file to the directory of the first HTML page. When you use the script the files will go into the that same directory. PM me if you need some more help

  9. #8
    Junior Member
    Join Date
    Apr 2005
    Posts
    4
    Member #
    9793
    this is the code i used with some help from this page and fallout.. but it still doesnt work
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <form action="uploadfile.php" method="post" enctype="multipart/form-data" class="content">
    <p>Password:
    <input type="password" name="password">
    <!-- Password is advisory, not nessecary -->
    </p>
    <p>Enter File Name:
    <input type="file" name="filetobeuploaded"></p>
    <input type="submit" value="Upload all information">
    <input type="reset" value="Reset">

    </body>
    </html>


    and this is my php file titled uploadfile.php:

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <?php
    print "<h1>Your data is being processed Joy!</h1><h1> . . . </h1><br>";
    if (strtolower ($password) === strtolower (password))
    {
    if ($filetobeuploaded == FALSE)
    {
    print "You did not mark a file for upload.<br>";
    }
    else
    {
    if ($HTTP_POST_FILES['filetobeuploaded']['size'] ><= 36)
    {
    print "<h4>Your file failed to upload!</h4><br>";
    print "The file size was larger than 35 MB.<br>";
    print "Please reduce it to a reasonable size and resent.<br>";
    }
    else
    {
    copy($HTTP_POST_FILES['filetobeuploaded']['tmp_name'],
    $HTTP_POST_FILES['filetobeuploaded']['name']);
    print "<h4>Thanks for helping us out and submitting a file!</h4><BR>";
    print "<h4>Your file has been stored on our system.<BR>";
    }
    } /*Edit: Whoopse, forgot one curly bracket here!*/
    } /*There we go!*/
    ?>
    </body>
    </html>


    www.digitallydrafted.com/upload/upload.htm is the link
    ok, now with that put, i thought everything was typed out correctly, but..
    when i pick the file to send, the php file doesnt say anything, the page goes to blank. And when i check my ftp server, there is no file. I know i have to be leaving one small thing out or something, if someone can help, i would be so appreciative
    thanks in advance
    mac

  10. #9
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    138 times
    Please do not triple post.

    if ($HTTP_POST_FILES['filetobeuploaded']['size'] ><= 36)

    ><= is not a comparison symbol. Use <= and it'll work. Said it worked when I did that (and after the folder in question had the correct permissons), however no file was uploaded.
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  11. #10
    Senior Member ceetee's Avatar
    Join Date
    Jul 2003
    Posts
    117
    Member #
    2035
    Can't remember what it was but some exploit used copy(), so move_uploaded_file() is safer. Anyway this worked with a small picture file I tried.

    uploadfile.php
    Code:
    <?php
    
    if (strtolower ($_POST['password']) === strtolower ("password"))
    {
      if (($_FILES['filetobeuploaded']['name']))
      {
        $maxFileSize = 36000000;
        if($_FILES['filetobeuploaded']['size'] > 0)
        {
          if(($_FILES['filetobeuploaded']['size']) <= $maxFileSize)
          {
            
    	$filename="images/".$_FILES['filetobeuploaded']['name'];
    	if(move_uploaded_file($_FILES['filetobeuploaded']['tmp_name'], $filename))
    	  echo "Upload succesful";
    	else  echo "File wasn't moved to folder";
          }
          else echo "File size exceeds $maxFileSize bytes";
        }
        else echo "File upload failed";
      }
      else echo "File not selected";
    }
    else echo "Wrong password";
    
    ?>


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:40 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com