•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 425,791 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,180 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 696 | Replies: 9
•
•
Join Date: May 2008
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
I am working on a 2 page form. I need to have a file upload on the first page. I need to pass the file upload values to the insert page. I am not sure what approach to take. I have tried sessions but had no luck.
Here is a simplified version of my code.
Page 1:
Page 2:
Page 3:
Need to get the upload values from Page1 - Page3
Thank you in advance,
Scott
Here is a simplified version of my code.
Page 1:
php Syntax (Toggle Plain Text)
<form method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <input name="userfile" type="file" id="userfile"> <input name="upload" type="submit" class="box" id="upload" value=" Upload "></td> </form>
Page 2:
php Syntax (Toggle Plain Text)
<form action="insert.php" method="post"> <input type="text" name="first" id="first" /> <input type="submit" name="button" id="button" value="Submit" /> </form>
Page 3:
php Syntax (Toggle Plain Text)
<?php $uploadDir = 'upload/'; if(isset($_POST['upload'])) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo "Error uploading file"; exit; } include 'includes/config.php'; include 'includes/opendb.php'; if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } $query = "INSERT INTO contacts (first, name, size, type, path ) ". "VALUES ('$first', '$fileName', '$fileSize', '$fileType', '$filePath')"; mysql_query($query) or die('Error, query failed : ' . mysql_error()); include 'includes/closedb.php'; echo "<br>Files uploaded<br>"; } ?>
Need to get the upload values from Page1 - Page3
Thank you in advance,
Scott
Last edited by peter_budo : May 11th, 2008 at 12:58 pm. Reason: Keep It Organized - please use [code] tags
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- File upload (PHP)
- Upload image from imagefield (ASP.NET)
- Preview an image before upload (JavaScript / DHTML / AJAX)
- pass variables across pages (PHP)
- Uploading multiple Images through input type="file" (PHP)
- Receiving closed filehandle warning (Perl)
- File Attachment Small Problem (PHP)
- Automating an FTP upload (Shell Scripting)
- vc++ mfc-i can't make getline work with a string for file input (C++)
Other Threads in the PHP Forum
- Previous Thread: Page Navigation
- Next Thread: Display Username



Threaded Mode