Professional Web Applications Themes

File Uploads - PHP Development

Hello You must use <form action="uploadItem.php" method="post" enctype="multipart/form-data"> gerwazy POLAND "Bert" <nospam.com> wrote in message news:bg0c8i$siu$1$8302bc10news.demon.co.uk... > Hi, > > I've just upgraded from php 4.0.6 to 4.2.3 and I'm having a lot of trouble > with image uploads. > > Under 4.0.6 I used this to upload images: > > upload.php > -------------------------------- > <form action="uploadItem.php" method="post"> > <input name="image" type="file"> > <input type="submit" value="upload image"> > </form> > --------------------------------- > > uploadItem.php > --------------------------------- > exec("mv $image > '/usr/local/home/httpd/vhtdocs/testing/uploads/images/1.jpg'"); > --------------------------------- > > But now under 4.2.3 this doesn't work. I know that my upload path is correct ...

  1. #1

    Default Re: File Uploads

    Hello
    You must use
    <form action="uploadItem.php" method="post" enctype="multipart/form-data">

    gerwazy
    POLAND




    "Bert" <nospam.com> wrote in message
    news:bg0c8i$siu$1$8302bc10news.demon.co.uk...
    > Hi,
    >
    > I've just upgraded from php 4.0.6 to 4.2.3 and I'm having a lot of trouble
    > with image uploads.
    >
    > Under 4.0.6 I used this to upload images:
    >
    > upload.php
    > --------------------------------
    > <form action="uploadItem.php" method="post">
    > <input name="image" type="file">
    > <input type="submit" value="upload image">
    > </form>
    > ---------------------------------
    >
    > uploadItem.php
    > ---------------------------------
    > exec("mv $image
    > '/usr/local/home/httpd/vhtdocs/testing/uploads/images/1.jpg'");
    > ---------------------------------
    >
    > But now under 4.2.3 this doesn't work. I know that my upload path is
    correct
    > as I can test the contents of the images dir with:
    >
    >
    if(file_exists('/usr/local/home/httpd/vhtdocs/testing/uploads/images/1.jpg')
    > )
    > {
    > echo "image exists";
    > }
    >
    > else
    > {
    > echo "no image";
    > }
    >
    > I have also looked at the permissions of the images dir and these are set
    to
    > 0777 which should work fine.
    >
    > My php.ini settings look like this:
    >
    > register_globals = off
    > safe_mode = off
    > file_uploads = 1
    > upload_tmp_dir = /tmp
    > upload_max_filesize - 2M
    >
    > Can anybody help?
    >
    > TIA,
    >
    > Bert.
    >
    >

    gerwazy Guest

  2. #2

    Default Re: File Uploads

    "Bert" <nospam.com> schrieb:
    > Can anybody help?
    Hope so.
    > <form action="uploadItem.php" method="post">
    This is not correct and it's strange that you claim that it worked. When
    you're uploading a file you have to add a correct enctype-Attribute to
    the form.

    <form action="uploadItem.php" method="post"
    enctype="multipart/form-data">

    Then you're doing this:
    > exec("mv $image
    > '/usr/local/home/httpd/vhtdocs/testing/uploads/images/1.jpg'");
    This won't work if register_globals is off. You can find the temporary
    filename on the webserver in $_FILES['image']['tmp_name']. And there's a
    better way to move the uploaded file to it's final location. Use the
    function move_uploaded_file(). You'll find the doentation at
    [url]http://www.php.net/manual/en/function.move-uploaded-file.php[/url]. Read it
    and have a look at the User Contributed Notes.

    Matthias
    Matthias Esken Guest

  3. #3

    Default Re: File Uploads


    "Bert" <nospam.com> schreef in bericht
    news:bg0c8i$siu$1$8302bc10news.demon.co.uk...
    > Hi,
    >
    > I've just upgraded from php 4.0.6 to 4.2.3 and I'm having a lot of trouble
    > with image uploads.
    >
    ....
    > But now under 4.2.3 this doesn't work. I know that my upload path is
    correct
    > as I can test the contents of the images dir with:
    >
    Look for the entry 'disable_functions' in your php.ini, it probably contains
    the exec() function.

    When it does, have a look at [url]http://www.php.net/move_uploaded_file[/url]


    JW



    Janwillem Borleffs Guest

  4. #4

    Default Re: File Uploads


    "Bert" <nospam.com> schreef in bericht
    news:bg0c8i$siu$1$8302bc10news.demon.co.uk...
    > Hi,
    >
    > I've just upgraded from php 4.0.6 to 4.2.3 and I'm having a lot of trouble
    > with image uploads.
    >
    ....
    > But now under 4.2.3 this doesn't work. I know that my upload path is
    correct
    > as I can test the contents of the images dir with:
    >
    Look for the entry 'disable_functions' in your php.ini, it probably contains
    the exec() function.

    When it does, have a look at [url]http://www.php.net/move_uploaded_file[/url]


    JW



    Janwillem Borleffs Guest

  5. #5

    Default Re: File Uploads

    "Bert" <nospam.com> wrote in message
    news:bg0c8i$siu$1$8302bc10news.demon.co.uk...
    > Hi,
    >
    > I've just upgraded from php 4.0.6 to 4.2.3 and I'm having a lot of trouble
    > with image uploads.
    >
    > Under 4.0.6 I used this to upload images:
    >
    > upload.php
    > --------------------------------
    > <form action="uploadItem.php" method="post">
    > <input name="image" type="file">
    > <input type="submit" value="upload image">
    > </form>
    > ---------------------------------
    >
    > uploadItem.php
    > ---------------------------------
    > exec("mv $image
    > '/usr/local/home/httpd/vhtdocs/testing/uploads/images/1.jpg'");
    > ---------------------------------
    >
    Unable to post follow up to all of your roups - comp.lang.php is not
    available on my server.

    Noting that register_globals are off, the file should be accessed as part of
    the $_FILES superglobal - detailed in
    [url]http://uk2.php.net/features.file-upload[/url]

    Rather than using a system exec call to move the file, look at
    [url]http://uk.php.net/manual/en/function.move-uploaded-file.php[/url]

    I use something like.....

    $filename = $_FILES['userfile']['tmp_name'];
    $realfile = $_FILES['userfile']['name'];
    if(!move_uploaded_file($filename, $image_dir."site_".$site_id.".jpg"))
    $retval = "There was a problem uploading the image file.";

    ....within my file upload function.

    HTH,

    Andy



    Andy Barfield Guest

  6. #6

    Default Re: File Uploads

    Thanks Andy,

    Fixed it like this:

    move_uploaded_file($_FILES['image']['tmp_name'],
    '/usr/local/home/httpd/vhtdocs/testing/uploads/images/' . '101.jpg');

    Simple ...

    Bert.

    "Andy Barfield" <abarfield_01> wrote in message
    news:3f23c1f0212.67.96.135...
    > "Bert" <nospam.com> wrote in message
    > news:bg0c8i$siu$1$8302bc10news.demon.co.uk...
    > > Hi,
    > >
    > > I've just upgraded from php 4.0.6 to 4.2.3 and I'm having a lot of
    trouble
    > > with image uploads.
    > >
    > > Under 4.0.6 I used this to upload images:
    > >
    > > upload.php
    > > --------------------------------
    > > <form action="uploadItem.php" method="post">
    > > <input name="image" type="file">
    > > <input type="submit" value="upload image">
    > > </form>
    > > ---------------------------------
    > >
    > > uploadItem.php
    > > ---------------------------------
    > > exec("mv $image
    > > '/usr/local/home/httpd/vhtdocs/testing/uploads/images/1.jpg'");
    > > ---------------------------------
    > >
    >
    > Unable to post follow up to all of your roups - comp.lang.php is not
    > available on my server.
    >
    > Noting that register_globals are off, the file should be accessed as part
    of
    > the $_FILES superglobal - detailed in
    > [url]http://uk2.php.net/features.file-upload[/url]
    >
    > Rather than using a system exec call to move the file, look at
    > [url]http://uk.php.net/manual/en/function.move-uploaded-file.php[/url]
    >
    > I use something like.....
    >
    > $filename = $_FILES['userfile']['tmp_name'];
    > $realfile = $_FILES['userfile']['name'];
    > if(!move_uploaded_file($filename, $image_dir."site_".$site_id.".jpg"))
    > $retval = "There was a problem uploading the image file.";
    >
    > ...within my file upload function.
    >
    > HTH,
    >
    > Andy
    >
    >
    >

    Bert Guest

  7. #7

    Default File Uploads

    I want to upload a file using cffile then have another page dynamically link to
    this file based on the username that a person is logged in with. For example,
    a client needs to view a pdf file (which is not uploaded into the database,
    only the path is) when he/she logs in. The pdf file is for this person only.
    I need a way to create a page where a person can upload the file and have the
    file linked to that person's record without having to manually input the file
    path into the db.

    Thanks


    ckainc Guest

  8. #8

    Default Re: File Uploads

    Have the cffile rename the uploaded file to correspond to the new persons name.
    Another alternative is to rename the new file using the primary index for that
    persons database record. So if the person who is logging in later happens to be
    record number 104 in the database then the pdf would be named 104.pdf. Also the
    page which is to display the link to that file would use the CFDIRECTORY tag to
    display all the files in the directory stored in the database for that user and
    you could set the FILTER to list all files starting with 104.


    GGRam Guest

  9. #9

    Default Re: File Uploads

    Thanks
    ckainc Guest

Similar Threads

  1. Web File uploads
    By DanShaw in forum Coldfusion Server Administration
    Replies: 0
    Last Post: February 7th, 04:57 PM
  2. Specify temp directory and file name for file uploads?
    By _jt in forum Macromedia ColdFusion
    Replies: 3
    Last Post: June 21st, 04:48 PM
  3. PHP and file uploads
    By OneSolution in forum PHP Development
    Replies: 7
    Last Post: November 25th, 05:36 AM
  4. File uploads and upload_tmp_dir
    By Xenofon Papadopoulos in forum PHP Development
    Replies: 1
    Last Post: November 25th, 05:17 AM
  5. Problems with File Uploads
    By Mathias Soeken in forum PHP Development
    Replies: 1
    Last Post: August 10th, 06:26 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139