Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 28th, 2005, 05:15 AM
Registered User
 
Join Date: Mar 2004
Location: Ikeja, Lagos, Nigeria.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to keph
Default Renaming a file during upload

Please do anyone know how I can rename a file while uploading it?
I posted this in the beginners forum and got not response.

===

This is my senario:
I upload form content into a database along with the file name of a picture file. Note, I store only the file name of the picture file in the database, the actuall file is stored in a folder on the server. This works perfectly.
However if two users have their picture files named the same way (e.g my_picture.jpg) only the first guy can upload. The second guy will have to change his file name or may actually end up deleting the first guys picture.
Is there a way I can dynamically rename pictures during the upload irrespective of what the user might have called his file?
Thanks all

http://www.kephassolutions.com
Reply With Quote
  #2 (permalink)  
Old October 6th, 2005, 07:14 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 101
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Moharo
Default

hey

that's no problem... all you have to do is generate certain file naming convention like so:

$new_filename = [userid] . "_" . microtime();

the renaming is done when you copy the file from $_POST array to folder like so:

<?php

copy($_FILES["image_upl"]["tmp_name"],[destination]);

?>

and that's it

if you are still not sure about this, let me know... peace

?>


www.campusgrind.com - college portal
Reply With Quote
Reply


Thread Tools
Display Modes

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Renaming long file name with VBA JillB Excel VBA 1 March 24th, 2008 06:20 PM
Renaming File ayazhoda Access VBA 3 April 24th, 2007 05:43 AM
subject: renaming a file w/ wildcards in name dgr7 Beginning VB 6 2 February 2nd, 2007 02:21 PM
Renaming remote mdb file elansolutionsltd Access VBA 7 November 11th, 2005 06:00 AM
Renaming File During Upload keph Beginning PHP 1 October 4th, 2005 02:46 PM



All times are GMT -4. The time now is 04:14 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.