Search
Left Quote    Treat your password like your toothbrush. Don't let anybody else use it, and get a new one every six months.
- Clifford Stoll    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: Uploading Files from a Common Directory.Urgen t Help
  This user is offline  abhi
  Subject: "Uploading Files from a Common Direc..." Posted: @ 8:02 pm on Nov 19 2007   
Member #: 379
Rank: User - (19)
Since: 07/30/07
Posts: 19
From: Michigan

Can anyone please tell me how to move all the files to a common directory and then give a command in PHP where it will upload all the files one by one from the directory and I dont have to enter the file names one by one.I run the following command where the last part xyz.txt is the filename .I change it everytime there is a new file.Herez the command:
php actimp.php emu_dw/*******@ IRIM1 szt_w_act.ctl xyz.txt.

Edited at 02:15:13 pm on 11/20/07


abhishekitty@ya
hoo.com |     Viewed: 7,329 Times | Reply to This | To top
  This user is offline  abhi
  Subject: "re: Uploading Files from a Common D..." Posted: @ 5:11 pm on Nov 20 2007    
Member #: 379
Rank: User - (19)
Since: 07/30/07
Posts: 19
From: Michigan

Herez the code that I need to change...!!!

Code:


<?php
// actimp.php
// Reads a act control loader and looks for '#INFILE#'
// Author: xxxx
// Date: 7/23/04

// Usage:
// php actimp.php <user/pass@d atabase> <control-fil e> <filename to import>


if($_SERVER['a rgc'] <> 4)
{
print("U sage: php actimp.php <user/pass@d atabase> <control-fil e> <filename to import>\n\ n";
exit(0);
}

if(!file_exists ($_SERVER['arg v'][2]))
{
print("E rror: Template control file does not exist.\n\n&q uot;
exit(1);
}
elseif(!file_ex ists($_SERVER[ 'argv'][3]))
{
print("E rror: Import file does not exist.\n\n&q uot;
exit(1);
}
elseif(strlen($ _SERVER['argv '][3]) <> 22)
{
print("E rror: Import file must use the following naming convention.\n n";
print(" tACT-YYYY-MM-D D.SSS.txt where SSS is the sequence number\n\n&q uot;
exit(1);
}
else{

$lines = file($_SERVER[ 'argv'][2]);
$newfile = false;
$newfile =fopen('temp.c tl', 'w');
if(!$newfile){
print("Er ror: Cannot create temporary control file ";
exit(2);
}
$impfile=$_SERV ER['argv'][3] ;
$date=substr($i mpfile,4,4).sub str($impfile,9, 2).substr($impf ile,12,2);
$seq=substr($im pfile,15,3);

foreach ( $lines as $line_num => $line) {

if(preg_match( "/#INFILE# /i", $line))
$line=str_repla ce("#INFI LE#",$_SE RVER['argv'][ 3],$line);
else if(preg_match( "/#DATE#/i ",$line))
$line=str_repla ce("#DATE #",$date, $line);
else if(preg_match( "/#INTEGER #/i",$lin e))
$line=str_repla ce("#INTE GER#",$se q,$line);

fwrite($newfile ,$line);
}

fclose($newfile );


$cmd= 'sqlldr userid='.$_SER VER['argv'][1 ].' control=temp.ct l log='.substr($ _SERVER['argv '][3],0,19).'l og';
passthru($cmd);
unlink('temp.c tl');

}

?>


the code...!!! I need to make changes to this code...!!!



Edited at 05:22:49 pm on 11/20/07


abhishekitty@ya
hoo.com |     Viewed: 7,305 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Uploading Files from a Common D..." Posted: @ 5:23 pm on Nov 20 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

I can't help you with this, sorry. I would say that you should upload them where you want to begin with. Or if you have a group you want to move, just move them via FTP or whatever, then begin saving them where you want the 1st time.




-bs0d | AllSyntax.com

    Viewed: 7,298 Times | Reply to This | To top
  This user is offline  abhi
  Subject: "re: Uploading Files from a Common D..." Posted: @ 8:55 pm on Nov 20 2007    
Member #: 379
Rank: User - (19)
Since: 07/30/07
Posts: 19
From: Michigan

How do you do them via FTP and save them...can you please send me soem code...!!! Can you also help me with another issue of username and passwword.




abhishekitty@ya
hoo.com |     Viewed: 7,292 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Uploading Files from a Common D..." Posted: @ 4:35 am on Nov 21 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA




-bs0d | AllSyntax.com

    Viewed: 7,282 Times | Reply to This | To top
  This user is offline  abhi
  Subject: "re: Uploading Files from a Common D..." Posted: @ 5:46 pm on Nov 26 2007    
Member #: 379
Rank: User - (19)
Since: 07/30/07
Posts: 19
From: Michigan

Hey bs0d....I am uploading one file at a time using the command that I mentioned...The issue is that I want to run just one command and (may be) store all the files in a common directory and the give the directory name once and then all the files should ne running one by one from the directory and I dont have to change the file name and run the same command again and again...!!!The command is still the same and I run the command in cmd prompt:
w:php actimp.php emu_dw/*******@ IRIM1 szt_w_act.ctl xyz.txt.
The part in bold is the file name and its a text file and after i run the command and loads it into SQL loader it creates a log file too...!!!



Edited at 05:51:03 pm on 11/26/07


abhishekitty@ya
hoo.com |     Viewed: 7,198 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank