![]() |
![]() |
||||||
|
|||||||
| Tags: |
![]() |
|
|||
|
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(); ?> > |
| Sponsored Links |
|
|||
|
I already tried that, and i always have this error:
ERROR:File 'c:\wamp\bin\mysql\mysql5.0.45\data\$uploadfile' . Somehow they cant detect the file path even though is specified in the top part of the code |
|
|||
|
I already tried that, and i always have this error:
ERROR:File 'c:\wamp\bin\mysql\mysql5.0.45\data\$uploadfile' . Somehow they cant detect the file path even though is specified in the top part of the code |
|
|||
|
The connotation of the 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:gan6qk$577$1@forums.macromedia.com... > Hi, good news! I managed to solve the problem. Turns out that the bug was > the connotation of the variable. Thanks a lot for your help!! |
|
|||
|
The connotation of the 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:gan6qk$577$1@forums.macromedia.com... > Hi, good news! I managed to solve the problem. Turns out that the bug was > the connotation of the variable. Thanks a lot for your help!! |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise