+ Reply to Thread
Results 1 to 7 of 7

Thread: How upload my files in different directoy???

  1. #1
    markosar200294 is offline x10Hosting Member markosar200294 is an unknown quantity at this point
    Join Date
    Sep 2010
    Posts
    56

    How upload my files in different directoy???

    I would like to upload my files in a different directory that html_plublic or tmp. I want to upload in a sub-directory html_plublic/materials. I am using PHP to upload but don´t let my upload files in a subdirectory, only in the html_plublic.
    Can you help me?
    Please.
    Last edited by markosar200294; 10-24-2010 at 04:55 AM.

  2. #2
    VPmase's Avatar
    VPmase is offline x10 Elder VPmase is an unknown quantity at this point
    Join Date
    Nov 2007
    Location
    Dixon, IL, USA
    Posts
    914

    Re: How upload my files in different directoy???

    Why don't you login to your CPanel and upload them from there? Go to your account panel and click Login to CPanel then when you log in find File Manager and use that.

  3. #3
    markosar200294 is offline x10Hosting Member markosar200294 is an unknown quantity at this point
    Join Date
    Sep 2010
    Posts
    56

    Re: How upload my files in different directoy???

    Ok, this is a god idea, but I want upload the files ONLY by web. My idea is that another person uploads this files without use the cpanel. This person doesn´t know programming lenguages. I programming this page for him.
    http://www.batepapoworkshops.x10.mx/

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: How upload my files in different directoy???

    I'm not sure how you're uploading files to "public_html" with PHP, as uploaded files are stored in the directory specified by upload_tmp_dir or, failing that, the TMPDIR environment variable (which should be "/tmp"). From there, you can move it wherever you wish using move_uploaded_file. If you need any more than that, you need to show us a minimal code example.

    Make sure you're not violating the X10 ToS. Free accounts aren't to be used for file hosting, nor are you to give others unfettered access. Restricting the upload directory means you're all right on the latter count, but I can't speak as to the former.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  5. #5
    bdistler's Avatar
    bdistler is offline x10 Lieutenant bdistler is an unknown quantity at this point
    Join Date
    May 2010
    Location
    Catalina AZ USA
    Posts
    349

    Re: How upload my files in different directoy???

    Quote Originally Posted by markosar200294 View Post
    I would like to upload my files in a different directory that html_plublic or tmp. I want to upload in a sub-directory html_plublic/materials. I am using PHP to upload but don´t let my upload files in a subdirectory, only in the html_plublic.
    Can you help me?
    Please.
    For a start what are the permissions set at for the sub-directory ?
    what if any error do you receive ?
    with what did you 'make' the sub-directory with ?
    is a file of the same name already in the sub-directory ?
    can you as a test upload to the sub-directory useing FTP ?

    Tell us more and we can help you more

  6. #6
    gomarc's Avatar
    gomarc is offline x10 Elder gomarc is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    USA
    Posts
    511

    Re: How upload my files in different directoy???

    Hi markosar200294,

    I would like to upload my files in a different directory that html_plublic or tmp.
    The secret is to move the uploaded file to your destination folder before the end of the script. PHP deletes the temporary upload after execution, so you just have to move it if you want to keep it. Doing it this way, allows you some control over what’s being uploaded.

    Allowing users to upload files this way is easy but it opens very big security risk. Make sure only authorized users have access to it, and restrict as much as you can what is to be uploaded. Remember that you are the one responsible for what’s in your site.

    For this example you will need to create 2 folders in your /public_html/
    • file_upload
    • materials
    In the file_upload place this form.html code:

    HTML Code:
    <html>
    <body>
    
    <form action="upload_file.php" method="post"
    enctype="multipart/form-data">
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file" />
    <br />
    <input type="submit" name="submit" value="Submit" />
    </form>
    
    </body>
    </html> 
    In the same folder create upload_file.php:

    PHP Code:
    <?php
    //Set the path relative to script location
    $destination_path "../materials/";

    //Some restrictions to the file upload
    if ((($_FILES["file"]["type"] == "image/gif")
    || (
    $_FILES["file"]["type"] == "image/jpeg")
    || (
    $_FILES["file"]["type"] == "image/pjpeg"))
    && (
    $_FILES["file"]["size"] < 20000))
      {
      if (
    $_FILES["file"]["error"] > 0)
        {
        echo 
    "Return Code: " $_FILES["file"]["error"] . "<br />";
        }
      else
        {
        echo 
    "Upload: " $_FILES["file"]["name"] . "<br />";
        echo 
    "Type: " $_FILES["file"]["type"] . "<br />";
        echo 
    "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
        echo 
    "Temp file: " $_FILES["file"]["tmp_name"] . "<br />";

        if (
    file_exists($destination_path $_FILES["file"]["name"]))
          {
          echo 
    $_FILES["file"]["name"] . " already exists. ";
          }
        else
          {
          
    move_uploaded_file($_FILES["file"]["tmp_name"],
          
    $destination_path $_FILES["file"]["name"]);
          echo 
    "Stored in: " $destination_path $_FILES["file"]["name"];
          }
        }
      }
    else
      {
      echo 
    "Invalid file";
      }
    ?>

    Go to your browser and open http://www.batepapoworkshops.x10.mx/...load/form.html and upload a small gif image. It will end up on http://www.batepapoworkshops.x10.mx/materials/

    Tested this on my free hosting (server: chopin) and it works with no problems.

    Code source and more information: http://www.w3schools.com/php/php_file_upload.asp

  7. #7
    markosar200294 is offline x10Hosting Member markosar200294 is an unknown quantity at this point
    Join Date
    Sep 2010
    Posts
    56

    Re: How upload my files in different directoy???

    I´m very happy for your ideas, I´m thank you a lot of. I´ll try this and answer you as soon as possible.
    Thank you again.

+ Reply to Thread

Similar Threads

  1. Where to Upload Files
    By paulzimbardo85 in forum Free Hosting
    Replies: 1
    Last Post: 10-23-2010, 07:25 PM
  2. i can't upload PHP files when i upload it it stoped
    By fthforum in forum Free Hosting
    Replies: 11
    Last Post: 06-04-2010, 05:25 PM
  3. Can I upload my pdf files?
    By laupkram in forum Off Topic
    Replies: 2
    Last Post: 08-20-2008, 03:03 PM
  4. HEEEEEEELP!!!!!! I remove every directoy
    By alvaro in forum Free Hosting
    Replies: 1
    Last Post: 10-11-2007, 05:05 PM
  5. Replies: 1
    Last Post: 10-03-2007, 01:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers