www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > PHP

    PHP Discussion and technical support for using and deploying PHP based websites.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 03-08-2006, 07:00 AM
    Dopple's Avatar
    Dopple Dopple is offline
    True Scotsman
     
    Join Date: Aug 2004
    Location: 70 klicks above the Do Lung bridge
    Posts: 650
    [RESOLVED]bokeh's uploader - slight amendment

    I used bokeh's uploader tute' to make an uploader that keeps a log in mysql which keeps track of the file names and then calls them back (an image gallery). Only thing is when I upload, the files all have weird numbers prefixing the filename "1141744557-test.gif" for example. Can anyone tell me what these numebr are, why they're there and what my options are to get rid of them?
    Thanks
    __________________
    grahammacleod.co.uk | my blog

    Last edited by Dopple; 03-15-2006 at 03:01 AM.
    Reply With Quote
      #2  
    Old 03-08-2006, 02:14 PM
    jogol jogol is offline
    backseat driver
     
    Join Date: Feb 2005
    Posts: 308
    the number is there so you donīt overwrite existing files that have the same name. it is done here:

    PHP Code:
    // make a unique filename for the uploaded file and check it is not already
    // taken... if it is already taken keep trying until we find a vacant one
    // sample filename: 1140732936-filename.jpg
    $now = time();
    while(
    file_exists($uploadFilename = $uploadsDirectory.$now.'-'.$_FILES[$fieldname]['name']))
    {
        
    $now++;
    }
    greetz
    __________________
    free music: comatronic
    Reply With Quote
      #3  
    Old 03-08-2006, 05:49 PM
    bokeh's Avatar
    bokeh bokeh is offline
    Keep it simple, stupid!
     
    Join Date: Jan 2005
    Location: Alicante (Spain)
    Posts: 7,708
    You can do as you please with the naming of the files. I chose to prefix the filename with a unix timestamp. The benifits are many. First the filenames will be unique; when doing a directory read the files will be listed in the order they were uploaded; and even if we are not using a database it is still simple to go into the image directory and get a list of files that were uploaded between two specific dates.

    Last edited by bokeh; 03-08-2006 at 05:57 PM.
    Reply With Quote
      #4  
    Old 03-13-2006, 07:54 AM
    Dopple's Avatar
    Dopple Dopple is offline
    True Scotsman
     
    Join Date: Aug 2004
    Location: 70 klicks above the Do Lung bridge
    Posts: 650
    Thanks. I see that now. I was just putting the original file name into the database! much appreciated guys.
    __________________
    grahammacleod.co.uk | my blog
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 04:21 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.