Loading ...
Sorry, an error occurred while loading the content.
 

Re: File linking/storage methods

Expand Messages
  • matthewbeirn
    I m new to PHP but currently working on a similar project. 1. Below is a simple start for uploading a file. 2. You can move the file to a directory Look at
    Message 1 of 4 , Nov 8, 2006
      I'm new to PHP but currently working on a similar project.
      1. Below is a simple start for uploading a file.
      2. You can move the file to a directory Look at
      the "move_uploaded_file()" function.
      3. Limit the directory's access.

      You'll need to create a function that tests the type of files the users
      can upload. You don't want users to upload scripts that will destroy
      your application.

      I don't currently have code to test for the type of file. Note,
      testing the extension of the file is not enough.

      gluck,
      m

      <?
      //Upload Form
      // In PHP earlier then 4.1.0, $HTTP_POST_FILES should be used instead
      //of $_FILES.
      if(!empty($_FILES["userfile"])) {
      $uploaddir = "/upload/" // set this to wherever
      //copy the file to some permanent location
      if (move_uploaded_file($_FILES["userfile"]["tmp_name"],
      $uploaddir . $_FILES["userfile"]["name"])) {
      echo("file uploaded");
      } else {
      echo ("error!");
      }
      }
      ?>


      <html>

      <form action="myupload.php" method=post enctype="multipart/form-data">
      submit this file: <input type=file name="userfile"><br>
      <input type=submit><br>
      </form>
      </html>


      --- In php-objects@yahoogroups.com, "teacherweeks" <teacherweeks@...>
      wrote:
      >
      > Good Evening Everyone,
      > I am wondering if anyone has a good method for dealing with the
      > following problem I have.
      >
      > 1. Need to be able to upload files to a website using PHP code.
      > 2. Need to be able to generate some type of link to files stated in
      #1.
      > 3. Need to be able to keep those links decently secure.
      >
      > I know that this is a lot, if anyone can help me with parts 1 & 2
      > those are the critcal ones. Finally, thanks to everyone ahead of time,
      > I know that this is the best source of information on the net
      > (interweb/tubes).
      >
      > David Weeks
      >
    • David Weeks
      Thanks, I will try that out for the file uploading. As for the security, I would just like some way to keep Joe shmoe from spoofing the link and getting
      Message 2 of 4 , Nov 9, 2006
        Thanks, I will try that out for the file uploading. As for the security, I
        would just like some way to keep Joe shmoe from "spoofing" the link and
        getting access to the file. I am working on setting up a paid lesson plan
        repository.

        David Weeks


        _____

        From: php-objects@yahoogroups.com [mailto:php-objects@yahoogroups.com] On
        Behalf Of Atkinson, Robert
        Sent: Wednesday, November 08, 2006 4:53 AM
        To: php-objects@yahoogroups.com
        Subject: RE: [php-objects] File linking/storage methods



        David, ESS Uploader (HYPERLINK
        "http://www.energyscripts.com/projects/essuploader/"http://www.energysc-ript
        s.com/-projects/-essuploader/) is a
        nice simple bit of kit to handle the upload.

        Once uploaded, I use a dynamic directory scan to find and list the uploaded
        files. Assuming you want something a little more secure, do you have any
        databases available to you?

        If you can explain a little more about how you expect the security to work
        in
        #3, I can help further.

        For instance, on one of my sites, you have to belong to a particular group
        to
        display a link to the file in that group. Each link is dynamically created
        and specific to the IP address of the person generating the list, so the
        link
        cannot be passed onto another person.

        The true name of the file is never given out. Instead, a content header is
        sent for the particular type of file, and the fie streamed to the recipient
        over a data link.

        Robert.

        -----Original Message-----
        From: HYPERLINK
        "mailto:php-objects%40yahoogroups.com"php-objects@-yahoogroups.-com
        [mailto:HYPERLINK
        "mailto:php-objects%40yahoogroups.com"php-objects@-yahoogroups.-com] On
        Behalf Of teacherweeks
        Sent: 08 November 2006 01:33
        To: HYPERLINK
        "mailto:php-objects%40yahoogroups.com"php-objects@-yahoogroups.-com
        Subject: [php-objects] File linking/storage methods

        Good Evening Everyone,
        I am wondering if anyone has a good method for dealing with the following
        problem I have.

        1. Need to be able to upload files to a website using PHP code.
        2. Need to be able to generate some type of link to files stated in #1.
        3. Need to be able to keep those links decently secure.

        I know that this is a lot, if anyone can help me with parts 1 & 2 those are
        the critcal ones. Finally, thanks to everyone ahead of time, I know that
        this
        is the best source of information on the net (interweb/tubes)-.

        David Weeks

        ************-*********-*********-*********-*********-*********-*********-***
        ******-********
        Any opinions expressed in email are those of the individual and not
        necessarily those of the company. This email and any files transmitted with
        it are confidential and solely for the use of the intended recipient or
        entity to who they are addressed. It may contain material protected by
        attorney-client privilege. If you are not the intended recipient, or a
        person responsible for delivering to the intended recipient, be advised that
        you have received this email in error and that any use is strictly
        prohibited.
        Random House Group +44 (0) 20 7840 8400
        HYPERLINK "http://www.randomhouse.co.uk"http://www.randomho-use.co.uk
        HYPERLINK
        "http://www.booksattransworld.co.uk"http://www.booksatt-ransworld.-co.uk
        HYPERLINK
        "http://www.kidsatrandomhouse.co.uk"http://www.kidsatra-ndomhouse.-co.uk
        ************-*********-*********-*********-*********-*********-*********-***
        ******-********






        --
        No virus found in this incoming message.
        Checked by AVG Free Edition.
        Version: 7.1.409 / Virus Database: 268.13.28/518 - Release Date: 11/4/2006



        --
        No virus found in this outgoing message.
        Checked by AVG Free Edition.
        Version: 7.1.409 / Virus Database: 268.13.28/518 - Release Date: 11/4/2006



        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.