The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
![]() |
File Upload Help - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Modules / Other (https://forums.formtools.org/forumdisplay.php?fid=8) +--- Forum: Modules (https://forums.formtools.org/forumdisplay.php?fid=16) +--- Thread: File Upload Help (/showthread.php?tid=126) |
File Upload Help - scaphis - Apr 23rd, 2009 For those who don't know - I just figured out why my upload was not working. Form Tools cannot create an file upload script for you - you have to do it yourself. First I made sure my server was configured for file uploads, and I had them add a tmp folder in the php ini settings. I dont know if that did anything but I will mention it anyway. Now- I found a script online for file uploads and I adapted it to work with my form. MAKE YOUR FORM START WITH THIS: <form action="<?php echo $_SERVER["PHP_SELF"]?>" method="post" enctype="multipart/form-data"> INSTEAD OF THIS: <form action="<?php echo $_SERVER["PHP_SELF"]?>" method="post"> Then add this below the submit button on your form: <?php if (isset($_POST['YOUR SUBMIT BUTTON NAME'])){ // Define the upload location $target_path = "c:\\"; // Create the file name with path $target_path = $target_path . basename( $_FILES['YOUR FILE FIELD NAME']['name']); // Try to move the file from the temporay directory to the defined. if(move_uploaded_file($_FILES['YOUR FILE FIELD NAME']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['YOUR FILE FIELD NAME']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } } ?> Replace these values with your own: YOUR FILE FIELD NAME YOUR SUBMIT BUTTON NAME That should make it so you can upload files with your own php form RE: File Upload Help - Jaace - Sep 21st, 2009 Will this work across multiple forms? Meaning, if my form has a second page and some of my uploads are on the first page and some on the second (which is my last page), will this allow me to save all that data at once. I remember it being a problem when trying to carry uploaded files in the SESSION or something like that. I had to resort to making a one page form that LOOKED like a two page form, kind of hackish and I didn't like it :/ |