General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 24th, 2003, 03:36 AM
Renjith Renjith is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Bangalore
Posts: 0 Renjith User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Renaming Of a File that Has Uploaded.

Hi,
In this module I have a user who logs in using his/her username and password. He/She is selecting a category, is able to upload files(html,gif,jpg) according to the category,A folder should create. and the folder name should be renamed to the file name that he is uploaded. and that file should be saved in the same folder. How do I go about it.

As I'm able to create the folders and upload the files in the respective folders, but not able to rename the folder.

Enclosing is the code that I'm using for creating the folders and uploading the files.


<?
session_start();

@ $username=$HTTP_SESSION_VARS['sess_user'];
@ $category=$HTTP_POST_VARS['category'];
@ $userfile=$HTTP_POST_FILES['userfile'];



$dirname='./' .$username;
$dirname1=$dirname. "/" . $category;
$dirname2="./" . $username . "/" . $category ."/" . "images";
$destination="./" . $username ."/" . $category ."/" . "images";
$path_to_file=$dirname1;


$flag=0;


if (@ mkdir($dirname,0777))
{
echo("successfully created Folder<br>");

}
else
{
$flag=1;
}
if (@ mkdir($dirname1,0777))
{
f
echo("Successfully created the Folder<br>");
}
else
{
//exit if;
$flag=1;

}

$dir=opendir($path_to_file);
while($file=readdir($dir))
{

if (!ereg("/$", $path_to_file))

$path_to_file = $path_to_file."/";
foreach ($userfile['name'] as $key=>$name)
{
if ($userfile['size'][$key])
{
// clean up file name
$name = ereg_replace("[^a-z0-9._]", "",
str_replace(" ", "_",
str_replace("%20", "_", strtolower($name)
)
)
);
$location = $path_to_file .$name;
while (file_exists($location))
$location .= ".copy";
@ copy($userfile['tmp_name'][$key],$location);
@ unlink($userfile['tmp_name'][$key]);
}
}

}
echo "\n Successfully uploaded file: $name.";
?>

Regards,
Renjith

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Renaming Of a File that Has Uploaded.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT