Professional Web Applications Themes

checking file ext before uploading and more - PHP Development

Also couldn't you do this? Have the form where the user selects file(s) to upload. The form does not point to actaully uploading the file yet. They click upload. This info gets sent to a php file that goes through that form data and verifies it then passes the info along to another php file that uploads it using and if statement and include_once or a redirect?...

  1. #1

    Default Re: checking file ext before uploading and more

    Also couldn't you do this?
    Have the form where the user selects file(s) to upload. The form does
    not point to actaully uploading the file yet. They click upload.
    This info gets sent to a php file that goes through that form data and
    verifies it then passes the info along to another php file that
    uploads it using and if statement and include_once or a redirect?
    SirPoonga Guest

  2. #2

    Default Re: checking file ext before uploading and more

    El Bucanero wrote:
    >>$filename = $HTTP_POST_FILES["picfile"]["name"];
    >>$ftype = $HTTP_POST_FILES["picfile"]["type"];
    >>$fsize = $HTTP_POST_FILES["picfile"]["size"];
    >
    >
    > Can I find some overview of all these variables? I looked on php.net but no
    > luck..
    Here's the doc:

    [url]http://www.php.net/manual/en/features.file-upload.php[/url]


    IroNiQ
    --
    Web: [url]http://ironiq.hu/[/url]
    Email: [email]ironironiq.hu[/email]

    Krisztian VASAS Guest

  3. Moderated Post

    Default Re: checking file ext before uploading and more

    Removed by Administrator
    El Bucanero Guest
    Moderated Post

  4. #4

    Default Re: checking file ext before uploading and more

    > $filename = $HTTP_POST_FILES["picfile"]["name"];
    > $ftype = $HTTP_POST_FILES["picfile"]["type"];
    > $fsize = $HTTP_POST_FILES["picfile"]["size"];
    Can I find some overview of all these variables? I looked on php.net but no
    luck..

    Thanks,
    Tim


    El Bucanero Guest

  5. #5

    Default Re: checking file ext before uploading and more

    > > I'm currently dabbling with a php image upload script.
    > > I've built in an ok extension checker which checks if the file is
    > > jpg or gif.
    > > Problem is, this extension checker only works AFTER the file is
    > > uploaded. I'd like it to work before that so a user wont
    > > accidentally upload some big wrong file and find out too late.
    > >
    > > Any ideas?
    > > Also, how do I do the same thing with filesize?
    > > I'd like a message to appear when the file is too big. (say, 150kb)
    > >
    > > Is there also a way to check for image dimensions?
    > > The files which are uploaded will be shown right away on a site and
    > > I'd prefer not to have huge pictures messing up my layout.
    For filesize you can use a hidden field:
    <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="153600">

    where value is the maximum filesize (in bytes). I don't think this produces an
    error, but it doesn't upload the file. This is easy to get around, so check
    with PHP too.

    AFAIK there's no way to check image dimensions in JS, though it's easy to do
    with PHP (getimagesize) and, if it's too big, adjust the height and width tags
    to the maximum you want to allow. I've done this on several projects and it
    usually works great. If you want to get fancy, you could even resize the images
    with ImageMagick or PHP image functions.

    Shawn
    --
    Shawn Wilson
    [email]shawnglassgiant.com[/email]
    [url]http://www.glassgiant.com[/url]
    Shawn Wilson Guest

  6. #6

    Default Re: checking file ext before uploading and more

    In article <NOPXa.47337$0W5.1282657pollux.casema.net>, El Bucanero
    <american_discoPANTShotmail.com> wrote:
    > (sorry if this message appears twice)
    >
    > Hey all,
    >
    > I'm currently dabbling with a php image upload script.
    > I've built in an ok extension checker which checks if the file is jpg or
    > gif.
    > Problem is, this extension checker only works AFTER the file is uploaded.
    > I'd like it to work before that so a user wont accidentally upload some big
    > wrong file and find out too late.
    >
    > Any ideas?
    >
    how about
    <input type="file" accept="image/gif,image/jpeg" name="file">

    --
    Richard Manley-Reeve
    Web & Multimedia Developer
    Gateshead College, Tyne & Wear

    (edit my email address before replying)


    ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
    [url]http://www.newsfeed.com[/url] The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
    Rich Manley-Reeve Guest

  7. #7

    Default Re: checking file ext before uploading and more

    Some javascript to serve you:
    <input
    type=file
    onchange='ext=this.value.substring(this.value.leng th-3);if(ext!="jpg"&&ext!=
    "gif"){alert("Images only, please!");this.value="";}'
    >
    Note: not tested, but should be ok.
    Ivo


    "Rich Manley-Reeve" <MY_FIRSTNAME.manley-reevegateshead.ac.uk> wrote in
    message news:180920031630168309%MY_FIRSTNAME.manley-reevegateshead.ac.uk...
    > In article <NOPXa.47337$0W5.1282657pollux.casema.net>, El Bucanero
    > <american_discoPANTShotmail.com> wrote:
    >
    > > (sorry if this message appears twice)
    > >
    > > Hey all,
    > >
    > > I'm currently dabbling with a php image upload script.
    > > I've built in an ok extension checker which checks if the file is jpg or
    > > gif.
    > > Problem is, this extension checker only works AFTER the file is
    uploaded.
    > > I'd like it to work before that so a user wont accidentally upload some
    big
    > > wrong file and find out too late.
    > >
    > > Any ideas?
    > >
    > how about
    > <input type="file" accept="image/gif,image/jpeg" name="file">
    >
    > --
    > Richard Manley-Reeve
    > Web & Multimedia Developer
    > Gateshead College, Tyne & Wear
    >
    > (edit my email address before replying)
    >
    >
    > ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet
    News==----
    > [url]http://www.newsfeed.com[/url] The #1 Newsgroup Service in the World! >100,000
    Newsgroups
    > ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
    =---


    Ivo Guest

Similar Threads

  1. Uploading File - Please Help :-)
    By Law808 in forum Macromedia Contribute General Discussion
    Replies: 3
    Last Post: March 2nd, 07:32 PM
  2. Checking files before uploading
    By gbert in forum Macromedia ColdFusion
    Replies: 10
    Last Post: April 20th, 06:14 PM
  3. Replies: 0
    Last Post: April 26th, 02:02 PM
  4. Help uploading a file please
    By Tom Lavier \(unmunge email before replying directly\) in forum PHP Development
    Replies: 7
    Last Post: December 5th, 05:15 PM
  5. uploading a file
    By Volkan Karaboša in forum ASP.NET General
    Replies: 1
    Last Post: August 6th, 02:13 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