473,394 Members | 1,737 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,394 software developers and data experts.

Renaming file before uploading to ftp via php

Hi I have this script that works for me but I want to add a date and or time of upload to the name of the file being uploaded, using this form, but want to keep the original file name as well . All because and incase of the same file name already exsiting on the server..

What function would I use and how would i script this please
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if ((($_FILES["file"]["type"] == "application/msword")
  3. || ($_FILES["file"]["type"] == "image/jpeg")
  4. || ($_FILES["file"]["type"] == "application/zip")
  5. || ($_FILES["file"]["type"] == "text/plain"))
  6. && ($_FILES["file"]["size"] < 20000))
  7.   {
  8.   if ($_FILES["file"]["error"] > 0)
  9.     {
  10.     echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
  11.     }
  12.   else
  13.     {
  14.     echo "Upload: " . $_FILES["file"]["name"] . "<br />";
  15.     echo "Type: " . $_FILES["file"]["type"] . "<br />";
  16.     echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
  17.     echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
  18.  
  19.     if (file_exists("upload/" . $_FILES["file"]["name"]))
  20.       {
  21.       echo $_FILES["file"]["name"] . " already exists. ";
  22.       }
  23.     else
  24.       {
  25.       move_uploaded_file($_FILES["file"]["tmp_name"],
  26.       "upload/" . $_FILES["file"]["name"]);
  27.       echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
  28.       }
  29.     }
  30.   }
  31. else
  32.   {
  33.   echo "Invalid file";
  34.   }
  35. ?>
Mar 23 '11 #1
0 1541

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

Similar topics

9
by: R. Rajesh Jeba Anbiah | last post by:
Q: How should I handle file upload? A: File uploading requires HTML form of content type "multipart/form-data". The file content has to be POSTed/submitted via the form and once the file is...
0
by: ¦è»P¦èµ^ | last post by:
Any homepage is for teaching file uploading in JAVA, JSP and TOMCAT, such as JSPSmartUpload? thx very much ~ ªÑ²¼»ù®æ¦³¤É¦³¶^, ¶R½æ­n¯à©Ó¾á­·ÀI ~ ~ Samba, more than a low cost File and...
0
by: praba kar | last post by:
Dear All, I have doubt regarding file uploading. When we upload a file to the remote server we can get file type through file extentions. How we can find out file type if a file doesn't have...
1
by: psb | last post by:
WHO HAS THE BEST COMPONENT FOR FILE UPLOAD? HELP!? has anyone achieved 100% success with HTTP uploading with Mac clients??? I thought the whole <input type="file" .../> was a w3c standard that...
4
by: Mukesh | last post by:
Hi all I am trying to upload and save as a picture to "root/Photos" folder in my web application. I am using this code to perform this task DirectoryInfo strFolder = new...
1
by: ali | last post by:
I am writing a script which uploads file to a specific directory; I am using javascript to handle client side exceptions and php script which actually performs file uploading. Php scripts gets...
7
by: yatin.smile | last post by:
I am a fresher in php and java script. that's wy i join a group for do a discussion on different concepts of php and java scripts. now i m working on file uploading.So i need a discussion on this...
3
ganesanji
by: ganesanji | last post by:
hi all, I have written a php coding for uploading a file to a specific folder or location in server which is a Linux server. I think the coding for file uploaing is correct. But it does not...
0
by: Raj | last post by:
Hello, I am planning to provide the Pause/Resume while uploading files. Our site is using both java applet and activex to do this. The list of selected files will be stored in an encrypted...
5
by: dmj07 | last post by:
Can anybody help me with a simple file uploading and retrieving idea? What I need is a simple system that uploads the files to be stored in a SQL database which are then shown on the front end in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.