www.webdeveloper.com
Page 11 of 23 FirstFirst ... 91011121321 ... LastLast
Results 151 to 165 of 340

Thread: How to: Upload images using PHP

  1. #151
    Join Date
    Jan 2005
    Location
    Alicante (Spain)
    Posts
    7,736
    Quote Originally Posted by blue-eye-labs
    I have wondered why you put the @ sign in front of a great many of your commands...
    To suppress the PHP error message. If PHP were to output an error message it would make sending headers impossible and then the redirect on error wouldn't work.

  2. #152
    Join Date
    Dec 2007
    Posts
    10
    How would I make it so it posts a URL to the image they uploaded?

  3. #153
    Join Date
    Jan 2005
    Location
    Alicante (Spain)
    Posts
    7,736

  4. #154
    Join Date
    Dec 2007
    Posts
    61

    Question

    Quote Originally Posted by bokeh
    That was just an example used in this script to ensure a unique file name.


    in adition to this uploaded file with the unique file name, like "0123456789-image.jpg".. how can i set this or what aditional code do i need to also make a thumbnail with img filename like; "tn_0123456789-image.jpg" ?

  5. #155
    Join Date
    Nov 2007
    Location
    Parts Unknown......
    Posts
    88
    I was wondering if there was a way to check to make sure the image uploaded is at least a certain resolution? Not sure how to check for that. Any suggestions?

    By the way, this script rocks!

  6. #156
    Join Date
    Aug 2007
    Location
    London
    Posts
    410

    resolved

    PHP Code:
    $src "path/to/image.jpg"//image location
    list($w$h) = getimagesize($src); //gets the image width/height

    $minWidth 800//minimum image width
    $minHeight 600//minimum image height

    if($w >= $minWidth && $h >= $minHeight) {

    do_stuff();

    } else {

     echo 
    "Sorry, image does not meet resolution requirements.";



  7. #157
    Join Date
    Nov 2007
    Location
    Parts Unknown......
    Posts
    88
    The image would have already had to be uploaded and then checked correct? I want to check while they are trying to upload it.

  8. #158
    Join Date
    Aug 2007
    Location
    London
    Posts
    410
    yeah it would have to be otherwise PHP can't work with it, it doesn't have to be stored though.

  9. #159
    Join Date
    Jul 2004
    Posts
    40
    Quote Originally Posted by bokeh
    You would need to make the success page dynamic and feed it the link through a query string.
    Thanks for this script - I have been struggling to get the uploading of images working properly for a long time!

    I am working on dynamic pages without a database. How do I implement a query string to the URL of my file with it's new name. This is going in my upload.success.php file & everything else in my other files is exactly as you have provided in your tutorial.

    I realise that the initial part of the absolute url is added to the page itself so it's getting the new file name I'd like help with please.

  10. #160
    Join Date
    May 2006
    Location
    Perth, Scotland
    Posts
    226
    Thats awesome dude,

    Thanks for clearing that up.
    1888.1985 2110.2012

  11. #161
    Join Date
    Dec 2007
    Posts
    61
    when a user uploads either one or multiple pics.., is there a way to also create in a separated folder, a .txt file for each pic, (named with the same pic name) containing the ip of the uploader??




    www is my root


    /www/images/uploaded
    (the uploaded images path)

    /www/images/logs
    (the path i want to store the .txt files)



    so if i upload "someimage.jpg" the loaded pic filename is something like:
    "1234567890-someimage.jpg"

    i need those .txt files with the same name in the logs dir., ie:
    "1234567890-someimage.jpg.txt"

    so i can later display a msg displaying:
    "uploaded by ip address xxx.xxx.xxx.xxx"

    thanks in advance

  12. #162
    Join Date
    May 2006
    Location
    Perth, Scotland
    Posts
    226
    I've never done this before... However WordPress creates new folders depending on the month for uploads.

    Sure it can be done.

    Somehow :S
    1888.1985 2110.2012

  13. #163
    Join Date
    Aug 2007
    Location
    London
    Posts
    410
    @knightman:

    Yes, this is possible. I would suggest using a mysql database instead, but in order to read and write files you use file() operations.
    Basically you use fopen("file", "mode") to open a file eg
    PHP Code:
    $file fopen("text_file.txt""w+"); 
    This will open the file "text_file.txt" in write mode.
    You can then write to the file using fwrite():
    PHP Code:
    fwrite($file"Hello!"); 
    I hope that that helps.

  14. #164
    Join Date
    Dec 2006
    Location
    Australia
    Posts
    47
    I had a post here, but found I had neglected to read the extra pages - seems I can't delete a post so I may as well explain why this is here.

  15. #165
    Join Date
    Dec 2006
    Location
    Australia
    Posts
    47
    After some reading, and finding that my issues were, as i suspected, already addressed here...

    I have to say thankyou for the excellent script. works beautifully.

    I do however have some questions in regards to bypassing the unique file name feature.
    Interested in using this code to update (overwrite) a single image manually. - eg: Journal page with an image I can update while in the field.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles