Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 28th, 2005, 05:15 AM
Registered User
 
Join Date: Mar 2004
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
 
Old October 6th, 2005, 07:14 PM
Friend of Wrox
 
Join Date: Jun 2003
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





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 03:21 PM
Renaming remote mdb file elansolutionsltd Access VBA 7 November 11th, 2005 07:00 AM
Renaming File During Upload keph Beginning PHP 1 October 4th, 2005 02:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.