Adobe Dreamweaver Forums



Last 10 THreads :         RoboHelp hanging (Last Post : shawntrident - Replies : 6 - Views : 7 )           »          RoboHelp & Knowledge Bases (Last Post : Captiv8r - Replies : 3 - Views : 4 )           »          Re: export image in D11 (Last Post : DAVID NAJAR - Replies : 1 - Views : 2 )           »          Cannot import audio into Captivate 3.0 (Last Post : ebowman77 - Replies : 2 - Views : 3 )           »          Dreamweaver MX vs Dreamweaver 4 (Last Post : bw75 - Replies : 0 - Views : 1 )           »          this will come in handy here. (Last Post : P@tty Ayers ~ACE - Replies : 9 - Views : 10 )           »          Seeking advise on flv in Captivate 3 (Last Post : 9060 - Replies : 0 - Views : 1 )           »          Global variables (Last Post : jfb00 - Replies : 0 - Views : 1 )           »          catching errors from remotely invoked processes (Last Post : Cr99 - Replies : 4 - Views : 5 )           »          Dreamweaver CS4 Beta Uninstaller? (Last Post : _Burn_ - Replies : 0 - Views : 1 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Dreamweaver: Main > Dreamweaver Application Development
 
Tags:



Reply
  #1 (permalink)  
Old 10-01-2008, 01:49 PM
taywanqi
 
Posts: n/a
Diggs:
Default Passing from data from one page to another

Hi All, i'm currently doing a CSV file upload into a database application, and
I'm wondering if it is possible to pass the data from the file field to another
php file which executes the command of inserting the data of the csv file into
the database? Thanks!!

Wanqi



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-01-2008, 01:49 PM
Murray *ACE*
 
Posts: n/a
Diggs:
Default Re: Passing from data from one page to another

Sure, although it's definitely easier to do it on the same page.

You could write the file data into a cookie, or pass it with a URL variable.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"taywanqi" <webforumsuser@macromedia.com> wrote in message
news:gal940$sj0$1@forums.macromedia.com...
> Hi All, i'm currently doing a CSV file upload into a database application,
> and
> I'm wondering if it is possible to pass the data from the file field to
> another
> php file which executes the command of inserting the data of the csv file
> into
> the database? Thanks!!
>
> Wanqi
>


Reply With Quote
  #3 (permalink)  
Old 10-01-2008, 01:49 PM
Murray *ACE*
 
Posts: n/a
Diggs:
Default Re: Passing from data from one page to another

Sure, although it's definitely easier to do it on the same page.

You could write the file data into a cookie, or pass it with a URL variable.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"taywanqi" <webforumsuser@macromedia.com> wrote in message
news:gal940$sj0$1@forums.macromedia.com...
> Hi All, i'm currently doing a CSV file upload into a database application,
> and
> I'm wondering if it is possible to pass the data from the file field to
> another
> php file which executes the command of inserting the data of the csv file
> into
> the database? Thanks!!
>
> Wanqi
>


Reply With Quote


  #4 (permalink)  
Old 10-01-2008, 01:49 PM
taywanqi
 
Posts: n/a
Diggs:
Default Re: Passing from data from one page to another

Hi Murray *ACE*,

First off, thanks a million for your reply. Currently my method of importing
the csv file into the database is to upload the file to a "uploads" folder that
i created, and then storing the file path in a variable before passing the
variable to the LOAD DATA INFILE query, which would then import the file into
the database. However, i keep getting this error:

ERROR:File 'c:\wamp\bin\mysql\mysql5.0.45\data\test\$target_p ath' not found
(Errcode: 2).

I have tried specifying the path to the exact uploads folder, but i still keep
getting the same error.

Could you show me an example or give me some pointers on how i should go about
importing the file into the database? For example, is it better to use cookies
to store the file path or would it be better to use a URL variable? Also, since
I am using a LOAD DATA INFILE query command, do i have to store everything to
an "uploads" folder, or can i just get the file straight from the file path
itself?

Many thanks, and I look forward to hearing from you soon.

Regards,
Wanqi

Reply With Quote
  #5 (permalink)  
Old 10-01-2008, 01:49 PM
taywanqi
 
Posts: n/a
Diggs:
Default Re: Passing from data from one page to another

Hi Murray *ACE*,

First off, thanks a million for your reply. Currently my method of importing
the csv file into the database is to upload the file to a "uploads" folder that
i created, and then storing the file path in a variable before passing the
variable to the LOAD DATA INFILE query, which would then import the file into
the database. However, i keep getting this error:

ERROR:File 'c:\wamp\bin\mysql\mysql5.0.45\data\test\$target_p ath' not found
(Errcode: 2).

I have tried specifying the path to the exact uploads folder, but i still keep
getting the same error.

Could you show me an example or give me some pointers on how i should go about
importing the file into the database? For example, is it better to use cookies
to store the file path or would it be better to use a URL variable? Also, since
I am using a LOAD DATA INFILE query command, do i have to store everything to
an "uploads" folder, or can i just get the file straight from the file path
itself?

Many thanks, and I look forward to hearing from you soon.

Regards,
Wanqi

Reply With Quote
  #6 (permalink)  
Old 10-01-2008, 01:49 PM
Murray *ACE*
 
Posts: n/a
Diggs:
Default Re: Passing from data from one page to another

Can you show us the code block for this process, please?

Also, you could pass the file data in a session variable if security is an
issue....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"taywanqi" <webforumsuser@macromedia.com> wrote in message
news:galrvt$ia9$1@forums.macromedia.com...
> Hi Murray *ACE*,
>
> First off, thanks a million for your reply. Currently my method of
> importing
> the csv file into the database is to upload the file to a "uploads" folder
> that
> i created, and then storing the file path in a variable before passing the
> variable to the LOAD DATA INFILE query, which would then import the file
> into
> the database. However, i keep getting this error:
>
> ERROR:File 'c:\wamp\bin\mysql\mysql5.0.45\data\test\$target_p ath' not
> found
> (Errcode: 2).
>
> I have tried specifying the path to the exact uploads folder, but i still
> keep
> getting the same error.
>
> Could you show me an example or give me some pointers on how i should go
> about
> importing the file into the database? For example, is it better to use
> cookies
> to store the file path or would it be better to use a URL variable? Also,
> since
> I am using a LOAD DATA INFILE query command, do i have to store everything
> to
> an "uploads" folder, or can i just get the file straight from the file
> path
> itself?
>
> Many thanks, and I look forward to hearing from you soon.
>
> Regards,
> Wanqi
>


Reply With Quote


  #7 (permalink)  
Old 10-01-2008, 01:49 PM
Murray *ACE*
 
Posts: n/a
Diggs:
Default Re: Passing from data from one page to another

Can you show us the code block for this process, please?

Also, you could pass the file data in a session variable if security is an
issue....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"taywanqi" <webforumsuser@macromedia.com> wrote in message
news:galrvt$ia9$1@forums.macromedia.com...
> Hi Murray *ACE*,
>
> First off, thanks a million for your reply. Currently my method of
> importing
> the csv file into the database is to upload the file to a "uploads" folder
> that
> i created, and then storing the file path in a variable before passing the
> variable to the LOAD DATA INFILE query, which would then import the file
> into
> the database. However, i keep getting this error:
>
> ERROR:File 'c:\wamp\bin\mysql\mysql5.0.45\data\test\$target_p ath' not
> found
> (Errcode: 2).
>
> I have tried specifying the path to the exact uploads folder, but i still
> keep
> getting the same error.
>
> Could you show me an example or give me some pointers on how i should go
> about
> importing the file into the database? For example, is it better to use
> cookies
> to store the file path or would it be better to use a URL variable? Also,
> since
> I am using a LOAD DATA INFILE query command, do i have to store everything
> to
> an "uploads" folder, or can i just get the file straight from the file
> path
> itself?
>
> Many thanks, and I look forward to hearing from you soon.
>
> Regards,
> Wanqi
>


Reply With Quote
  #8 (permalink)  
Old 10-01-2008, 01:49 PM
taywanqi
 
Posts: n/a
Diggs:
Default Re: Passing from data from one page to another

Attached below is the code i used for my application:

form.php







<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style13 { color: #FFFFFF;
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 14px;
}
-->
</style>
</head>

<body>
<form id="form1" name="form1" enctype="multipart/form-data" method="post"
action="test.php">
<p align="center">
<input type="file" name="fileupload" id="fileupload" />
<input type="hidden" name="csvfile" id="csvfile"/>

</p>
<p align="center">
<input type="submit" name="upload" id="upload" value="Submit" />
</p>
</form>
</body>
</html>


Test.php

<?php
session_start();
echo $name;
ob_start();
?>

<?php require_once('connection.php'); ?>

<?php

//UPLOADING FILE
if(isset($_POST['upload']))
{

$uploaddir = 'uploads';

$uploadfile = $uploaddir . basename($_FILES['fileupload']['name']);

$target_path = $_GET['uploadfile'];

echo $target_path;

//$target_path = ini_get('$uploadfile');

echo $file;

echo '<pre>';
if (move_uploaded_file($_FILES['fileupload']['tmp_name'], $uploadfile)) {

echo "File is valid, and was successfully uploaded.\n";

} else {
echo "Possible file upload attack!\n";
}

echo 'Here is some more debugging info:';
print_r($_FILES);

print "</pre>";
}


$fcontents = $_SESSION[csvfile];

for($i=0; $i<sizeof($fcontents); $i++) {

$line = trim($fcontents[$i]);
$arr = explode("\t", $line);

echo $arr."<br>\n";


}

//ATTRIBUTES
//$fieldseparator = ',';
//$lineseparator = '\n';

//READING OF FILE
$csvfile = $uploaddir . basename($_FILES['fileupload']['name']);

//TRUNCATE THE FILE BEFORE INSERTING IT INTO THE DATABASE
mysql_select_db($database, $test);
mysql_query("TRUNCATE TABLE timetable") or die("MySQL Error: " .
mysql_error()); //Delete the existing rows

//IMPORT CSV INTO DATABASE
$lines = 0;
$queries = "";
$linearray = array();
$fcontents = file($csvfile);

for($i=0; $i<sizeof($fcontents); $i++) {

$lines++;

$line = trim($fcontents[$i]);

$linearray = explode(',',$line);

$linemysql = implode("','",$linearray); // convert the array to a string

echo "$linemysql". "\n";

//$query = "INSERT INTO timetable values('$linemysql')";//Insert query to
insert values into the database
$query = 'LOAD DATA INFILE "$target_path" REPLACE
INTO TABLE timetable
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY """"
LINES TERMINATED BY "\r\n"';

mysql_query($query, $test) or die('SQL ERROR:'.mysql_error()); //Insert in
the new values into the database

}

?>

</head>
<body>
</body>
</html>
<?php ob_flush(); ?>

Reply With Quote
  #9 (permalink)  
Old 10-01-2008, 01:49 PM
taywanqi
 
Posts: n/a
Diggs:
Default Re: Passing from data from one page to another

Attached below is the code i used for my application:

form.php







<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style13 { color: #FFFFFF;
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 14px;
}
-->
</style>
</head>

<body>
<form id="form1" name="form1" enctype="multipart/form-data" method="post"
action="test.php">
<p align="center">
<input type="file" name="fileupload" id="fileupload" />
<input type="hidden" name="csvfile" id="csvfile"/>

</p>
<p align="center">
<input type="submit" name="upload" id="upload" value="Submit" />
</p>
</form>
</body>
</html>


Test.php

<?php
session_start();
echo $name;
ob_start();
?>

<?php require_once('connection.php'); ?>

<?php

//UPLOADING FILE
if(isset($_POST['upload']))
{

$uploaddir = 'uploads';

$uploadfile = $uploaddir . basename($_FILES['fileupload']['name']);

$target_path = $_GET['uploadfile'];

echo $target_path;

//$target_path = ini_get('$uploadfile');

echo $file;

echo '<pre>';
if (move_uploaded_file($_FILES['fileupload']['tmp_name'], $uploadfile)) {

echo "File is valid, and was successfully uploaded.\n";

} else {
echo "Possible file upload attack!\n";
}

echo 'Here is some more debugging info:';
print_r($_FILES);

print "</pre>";
}


$fcontents = $_SESSION[csvfile];

for($i=0; $i<sizeof($fcontents); $i++) {

$line = trim($fcontents[$i]);
$arr = explode("\t", $line);

echo $arr."<br>\n";


}

//ATTRIBUTES
//$fieldseparator = ',';
//$lineseparator = '\n';

//READING OF FILE
$csvfile = $uploaddir . basename($_FILES['fileupload']['name']);

//TRUNCATE THE FILE BEFORE INSERTING IT INTO THE DATABASE
mysql_select_db($database, $test);
mysql_query("TRUNCATE TABLE timetable") or die("MySQL Error: " .
mysql_error()); //Delete the existing rows

//IMPORT CSV INTO DATABASE
$lines = 0;
$queries = "";
$linearray = array();
$fcontents = file($csvfile);

for($i=0; $i<sizeof($fcontents); $i++) {

$lines++;

$line = trim($fcontents[$i]);

$linearray = explode(',',$line);

$linemysql = implode("','",$linearray); // convert the array to a string

echo "$linemysql". "\n";

//$query = "INSERT INTO timetable values('$linemysql')";//Insert query to
insert values into the database
$query = 'LOAD DATA INFILE "$target_path" REPLACE
INTO TABLE timetable
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY """"
LINES TERMINATED BY "\r\n"';

mysql_query($query, $test) or die('SQL ERROR:'.mysql_error()); //Insert in
the new values into the database

}

?>

</head>
<body>
</body>
</html>
<?php ob_flush(); ?>

Reply With Quote


  #10 (permalink)  
Old 10-01-2008, 01:49 PM
Murray *ACE*
 
Posts: n/a
Diggs:
Default Re: Passing from data from one page to another

You have this in test.php -

$target_path = $_GET['uploadfile'];

That implies that the page calling test.php is passing 'uploadfile' as a URL
variable. But it isn't.

<form id="form1" name="form1" enctype="multipart/form-data" method="post"
action="test.php">

Why wouldn't $target_path be the same as $uploadfile?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"taywanqi" <webforumsuser@macromedia.com> wrote in message
news:gam4sp$scm$1@forums.macromedia.com...
> Attached below is the code i used for my application:
>
> form.php
>
>
>
>
>
>
>
> <?php
> session_start();
> ?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> <title>Untitled Document</title>
> <style type="text/css">
> <!--
> .style13 { color: #FFFFFF;
> font-family: Georgia, "Times New Roman", Times, serif;
> font-size: 14px;
> }
> -->
> </style>
> </head>
>
> <body>
> <form id="form1" name="form1" enctype="multipart/form-data" method="post"
> action="test.php">
> <p align="center">
> <input type="file" name="fileupload" id="fileupload" />
> <input type="hidden" name="csvfile" id="csvfile"/>
>
> </p>
> <p align="center">
> <input type="submit" name="upload" id="upload" value="Submit" />
> </p>
> </form>
> </body>
> </html>
>
>
> Test.php
>
> <?php
> session_start();
> echo $name;
> ob_start();
> ?>
>
> <?php require_once('connection.php'); ?>
>
> <?php
>
> //UPLOADING FILE
> if(isset($_POST['upload']))
> {
>
> $uploaddir = 'uploads';
>
> $uploadfile = $uploaddir . basename($_FILES['fileupload']['name']);
>
> $target_path = $_GET['uploadfile'];
>
> echo $target_path;
>
> //$target_path = ini_get('$uploadfile');
>
> echo $file;
>
> echo '<pre>';
> if (move_uploaded_file($_FILES['fileupload']['tmp_name'], $uploadfile)) {
>
> echo "File is valid, and was successfully uploaded.\n";
>
> } else {
> echo "Possible file upload attack!\n";
> }
>
> echo 'Here is some more debugging info:';
> print_r($_FILES);
>
> print "</pre>";
> }
>
>
> $fcontents = $_SESSION[csvfile];
>
> for($i=0; $i<sizeof($fcontents); $i++) {
>
> $line = trim($fcontents[$i]);
> $arr = explode("\t", $line);
>
> echo $arr."<br>\n";
>
>
> }
>
> //ATTRIBUTES
> //$fieldseparator = ',';
> //$lineseparator = '\n';
>
> //READING OF FILE
> $csvfile = $uploaddir . basename($_FILES['fileupload']['name']);
>
> //TRUNCATE THE FILE BEFORE INSERTING IT INTO THE DATABASE
> mysql_select_db($database, $test);
> mysql_query("TRUNCATE TABLE timetable") or die("MySQL Error: " .
> mysql_error()); //Delete the existing rows
>
> //IMPORT CSV INTO DATABASE
> $lines = 0;
> $queries = "";
> $linearray = array();
> $fcontents = file($csvfile);
>
> for($i=0; $i<sizeof($fcontents); $i++) {
>
> $lines++;
>
> $line = trim($fcontents[$i]);
>
> $linearray = explode(',',$line);
>
> $linemysql = implode("','",$linearray); // convert the array to a string
>
> echo "$linemysql". "\n";
>
> //$query = "INSERT INTO timetable values('$linemysql')";//Insert query to
> insert values into the database
> $query = 'LOAD DATA INFILE "$target_path" REPLACE
> INTO TABLE timetable
> FIELDS TERMINATED BY ","
> OPTIONALLY ENCLOSED BY """"
> LINES TERMINATED BY "\r\n"';
>
> mysql_query($query, $test) or die('SQL ERROR:'.mysql_error()); //Insert
> in
> the new values into the database
>
> }
>
> ?>
>
> </head>
> <body>
> </body>
> </html>
> <?php ob_flush(); ?>
>


Reply With Quote
Reply


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 08:26 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk