The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
|
[urgent] File upload once again - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1) +--- Forum: API (https://forums.formtools.org/forumdisplay.php?fid=17) +--- Thread: [urgent] File upload once again (/showthread.php?tid=1333) |
[urgent] File upload once again - asgaroth - May 30th, 2011 Hey there, i read myself through the many threads about file uploading but could not find a solution. Its a bit urgent because i need file uploading working at the end of the week... My Problem is as follows: 1. form definition looks like this: <form name="regform" action="<?=$_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data"> 2. clicking upload works, a var_dump($_FILES); gives me the uploaded files and the temp_names and so on. 3. Im passing the file array to the ft_api_process_form : $params = array( "submit_button" => "weiter", "next_page" => "confirm.php", "form_data" => $_POST, "file_data" => $_FILES ); ft_api_process_form($params); 4. On the confirmation page, there is nothing in $fields['upload1']; (I also tried $fields['upload1']['name']; ) The files are not stored in the upload directory! I cannot verify uploads via the Admin panel because i couldn't upload files in my test submission and therefore the inputs are not recognized! I however tested file upload with a simple file upload script unrelated to formtools. Questions: q1) The files are not renamed from temporary to desired name, do i still have to use a script like the one mentioned here: http://forums.formtools.org/showthread.php?tid=126 ? q2) Does ft_api_process_form() store the file values in the fields array too? E.g. is $fields['upload1']; valid if the file input was named upload1 ? Or do i have to use $fields['upload1']['name']; ? Thanks in advance for replies! RE: [urgent] File upload once again - Ben - May 30th, 2011 Hi Asgaroth, Sorry you're having trouble! Quote:I cannot verify uploads via the Admin panel because i couldn't upload files in my test submission and therefore the inputs are not recognized! I however tested file upload with a simple file upload script unrelated to formtools. I'd still start by testing it within Form Tools - that'll check that the paths are all working as Form Tools sees it. To do this, just do to your Edit Form -> Fields tab and temporarily change one of your fields to a file field, then edit any submission and try uploading a file. That'll let you know if that much is working - if it's NOT, then go to your Settings -> Files tab and take a good look at the settings defined there: that'll be the problem! I'd definitely do this before looking at the API code, just to eliminate this as the cause. - Ben RE: [urgent] File upload once again - asgaroth - May 30th, 2011 Thanks for the fast reply! I tried what you told me to try. Uploading via the administrator Panel worked! So what is left is the question why nothing is passed to the next page with the file_data parameter... How can i show if the files where submitted correctly? Is accessing it by $fields['uploadfield'] correct? Cheers, asgaroth (May 30th, 2011, 4:51 AM)Ben Wrote: Hi Asgaroth, RE: [urgent] File upload once again - Ben - Jun 3rd, 2011 Quote:Is accessing it by $fields['uploadfield'] correct? Ah, no! I don't think so... if that will contain anything, it will contain the filename. (I'll have to look into that). Could you confirm via an FTP client that the file was, in fact uploaded? - Ben RE: [urgent] File upload once again - asgaroth - Jun 3rd, 2011 Thanks for the reply! I have confirmed that the file was uploaded (i have shell access on that machine). I now use kind of a workaround for that file problem... For copying the uploaded files into the target upload directory, i use something like in the older thread i linked to in my first post: Code: // Define the upload location For displaying i store the filenames into some new field inside of the session (kind of abusing it). Code: $_SESSION[form_tools_form]['uploadname1] = $filename; I can then access $fields['uploadname1'] on the next page (after $fields = ft_api_init_form_page(); Like this it works for me. (Jun 3rd, 2011, 1:33 AM)Ben Wrote:Quote:Is accessing it by $fields['uploadfield'] correct? RE: [urgent] File upload once again - Ben - Jun 5th, 2011 Good, I'm glad you found a workaround! - Ben |