473,385 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

automatically rename uploaded file

how to automatically rename the uploaded file if someone is coming to upload his file and if it has the name of anybody else file name i dont want the new to replace the old so i want the server to rename automatically the uploaded file.. thanks..
Apr 1 '08 #1
2 2086
Markus
6,050 Expert 4TB
how to automatically rename the uploaded file if someone is coming to upload his file and if it has the name of anybody else file name i dont want the new to replace the old so i want the server to rename automatically the uploaded file.. thanks..
Well, using file_exists() you'd check to see if the file name is already present - if it is you then assign a random name to it - rand() - and then save the file.

Pretty simple :)
Apr 1 '08 #2
aktar
105 100+
[PHP]if (file_exists($_FILE['name'])){

//do something with the $_FILE['name']

}

move_uploaded_file ( $_FILE['temp_name', $_FILE['name'] )[/PHP]

regards
Apr 1 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: smilesinblues | last post by:
Hi, I have to allow my visitors to upload image on my site. I am using the follwoing code to do that: $uploaddir = 'admin/'; $uploadfile = $uploaddir . basename($_FILES);...
17
by: tom | last post by:
Hello, got a prob with renaming a file; still don't know where is the mistake. this is the code: <% '*************************************************************************** *...
2
by: Shaker | last post by:
Hello, I would like to write a program that would automatically take out the spaces in directory names and file names . I would like this because my web server does not allow spaces in names. I...
2
by: Simon | last post by:
I'm following microsoft's guide on how to upload files. I want to upload AND rename the file... Anyone have some tips for how to do that? Thanks ------ If Not File1.PostedFile Is Nothing And...
4
by: Dynamo | last post by:
I am trying to upload a file and then rename the file as something else. Everything worked fine unless the renamed filename already existed. So I added some extra code to check if the filename...
12
by: mantrid | last post by:
Im trying to move a file but am having luck my code is below. The temp and target paths are valid as they echo correctly. but I cant get the copy() function to work, or the rename() function ...
1
by: hardik | last post by:
can anyone tell me how i can change the filename which is going to uploaded here is a code for uploading a file <!-- #include file="clsUpload.asp" --> Set objUpload = New clsUpload If...
3
by: gsoguerrilla | last post by:
Hi, I have limited knowledge in php and I am having trouble with uploading an image to a remote directory and resizing it if it's larger and renaming it to a unique id, while at the same time I...
4
by: PHPstarter | last post by:
Hi guys. I'm having a problem with this case. I want a php script activated by a standard file submit to: 1) upload the file to ../../upload 2) copy the file to a directory further back, for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.