FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[urgent] File upload once again
#1
Exclamation 
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!
Reply
#2
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

Reply
#3
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,

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
Reply
#4
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
Reply
#5
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
$target_path = "/somewhere/";

// Create the file name with path
$filename = 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 . $filename )) {
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!";
}
}

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?

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

Reply
#6
Good, I'm glad you found a workaround! Smile

- Ben
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)