Private Label and Cobranded VoIP Solutions
BrainCast internet & phone based message/memo recording & reminder organization system
Internet Phone Service and Broadband Phone Service by ViaTalk

Go Back   VoIP Forums, Internet Phone Service Forums, & Web Hosting Forums > CoderForums - Programming Discussion > General Programming Issues > Programming Languages & Technologies > PHP

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-26-2002, 03:42 PM
leebo leebo is offline
Registered User
 
Join Date: Feb 2002
Posts: 4
Help !

I need to know if you could possibly help me ??

I have to upload a file lets say....c:/windows/desktop/picture.gif

I need to change the name of the file before
saving it to the server the name will come through on the form with the file
path etc...

i.e upload.php?changename=example

this making the filename example.gif instead of the picture.gif

Could you please help me i`m so lost.

Regards

Lee
__________________
.........what ya lookin at..........
Reply With Quote
  #2  
Old 02-26-2002, 09:59 PM
Millencolin Millencolin is offline
Registered User
 
Join Date: Feb 2002
Posts: 49
Send a message via AIM to Millencolin
Umm can't you just rename it on your computer? Or when you upload it, you can usually rename the file to whatever you want.
I would just rename it before i upload it, like normally, right click and "rename" it.
Unlesss your talking about something else that i have no idea of what your saying.
Reply With Quote
  #3  
Old 02-27-2002, 02:50 AM
leebo leebo is offline
Registered User
 
Join Date: Feb 2002
Posts: 4
No i`m building a site for users to upload a picture of them selves but say 2 people have the picture lee.gif then it will overwrite one another so i need to have some code that will rename all files to the users username before uploading.

i.e. if you wanted to have a button on here where people could upload a picture of them selves and had over 20,000 members then someone could have the same gif name and would cause a problem.

Cheers
__________________
.........what ya lookin at..........
Reply With Quote
  #4  
Old 02-27-2002, 03:02 AM
Hitek Hitek is offline
Registered User
 
Join Date: Feb 2002
Posts: 1
Send a message via ICQ to Hitek
Last time I checked, when a user uploaded a file through a php script, it was required to copy the file from the temp directory to it's permanent home.
You can simply rename the file inside the copy function.
__________________
Keith
Reply With Quote
  #5  
Old 02-27-2002, 01:40 PM
leebo leebo is offline
Registered User
 
Join Date: Feb 2002
Posts: 4
Yes it does copy it first into a temp directory then copys into the web server. But do you know how to rename the file whilst in the temp folder ? I more of a asp person not php but need this working for my site.

Cheers
__________________
.........what ya lookin at..........
Reply With Quote
  #6  
Old 02-27-2002, 04:48 PM
Sintax Sintax is offline
Registered User
 
Join Date: Feb 2002
Posts: 4
Send a message via ICQ to Sintax
I just made a script were people upload images and it displays it... It maybe what your looking for. if not you can see how i rename the files.

http://www.hotscripts.com/Detailed/14189.html
Reply With Quote
  #7  
Old 03-11-2002, 11:18 PM
el_robert el_robert is offline
Registered User
 
Join Date: Mar 2002
Posts: 2
this is in no way complete but hopefully it will get you going in the right direction.

All it does is take the uploaded file named "$myfile" and renames it by prepending the user name and a hyphen to the original name.

When you need to get the right file, just use :
PHP Code:
$ar explode("-",$image_file_name);
$user_name $ar[0]; 
this is assuming you don't allow hyphens in the user name.

It works pretty well for me, there is about 140,000 images that were uploaded this way so far and no problems.

form:
Code:
<form ENCTYPE="multipart/form-data" method=post action=process_upload.php>
<input name=myfile type=file>
<input type=submit value="Click to upload">
</form>

process_upload:
PHP Code:
//get the original file name
$og_name $HTTP_POST_FILES['userfile']['name'];

//set the path where it is going to go
$path "/my/path/";

//set the new file name by prepending the user name to the original file name
$new_file_name $path.$user_name."-".$og_name;

//move it
move_uploaded_file($myfile,$new_file_name); 
Reply With Quote
Reply

Thread Tools
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 On
HTML code is Off
Forum Jump