Welcome Guest, Not a member yet? Register   Sign In
Uploading Multiple Files As Email Attachment
#11

[eluser]TheFuzzy0ne[/eluser]
The upoload_data() method has not been overridden, so I'm surprised it returns anything at all, to be honest. You should be using $this->upload->get_multi_upload_data(). Smile

#12

[eluser]TheFuzzy0ne[/eluser]
[quote author="RaGe10940" date="1364500109"]And if PHP the right way is your website then I love you <3 Tongue[/quote]

No, it's not my Web site (although I wish it was!), but it's something I completely agree with, and support entirely.
#13

[eluser]RaGe10940[/eluser]
Okay it's me again and now I got the array issue fixed and what not...

Now i am kinda confused on how to get the ['full_path'] to be attached ?

this is the array :

Code:
array(2) { [0]=> array(14) { ["file_name"]=> string(8) "test.txt" ["file_type"]=> string(10) "text/plain" ["file_path"]=> string(35) "/usr/local/var/www/Test/ci/uploads/" ["full_path"]=> string(43) "/usr/local/var/www/Test/ci/uploads/test.txt" ["raw_name"]=> string(4) "test" ["orig_name"]=> string(8) "test.txt" ["client_name"]=> string(8) "test.txt" ["file_ext"]=> string(4) ".txt" ["file_size"]=> float(0.01) ["is_image"]=> bool(false) ["image_width"]=> string(0) "" ["image_height"]=> string(0) "" ["image_type"]=> string(0) "" ["image_size_str"]=> string(0) "" } [1]=> array(14) { ["file_name"]=> string(9) "test2.txt" ["file_type"]=> string(10) "text/plain" ["file_path"]=> string(35) "/usr/local/var/www/Test/ci/uploads/" ["full_path"]=> string(44) "/usr/local/var/www/Test/ci/uploads/test2.txt" ["raw_name"]=> string(5) "test2" ["orig_name"]=> string(9) "test2.txt" ["client_name"]=> string(9) "test2.txt" ["file_ext"]=> string(4) ".txt" ["file_size"]=> float(0.01) ["is_image"]=> bool(false) ["image_width"]=> string(0) "" ["image_height"]=> string(0) "" ["image_type"]=> string(0) "" ["image_size_str"]=> string(0) "" } }

I get both test2.txt and test1.txt both get uploaded...

this is how I am calling the data :

$return = $this->upload->get_multi_upload_data();

$file = $return['full_path'];

$this->email->attach($file);

I just did a var_dump on $file and a get a big fat NULL.

Why so?!

the var_dump of $return gives me a big array but $file gives me NULL?

Confused Sad
#14

[eluser]RaGe10940[/eluser]
https://github.com/stvnthomas/CodeIgniter-Multi-Upload

is the library I am using
#15

[eluser]RaGe10940[/eluser]
Code:
$file = $this->upload->get_multi_upload_data('full_path');

using that gives me the entire array not just the full_path so i can attach it the email.
#16

[eluser]TheFuzzy0ne[/eluser]
Let me reformat the array you posted above (which next time, you can do yourself Wink), and then hopefully you'll see the bigger picture.

Code:
array(2) {
    [0]=> array(14) {
        ["file_name"]=> string(8) "test.txt"
        ["file_type"]=> string(10) "text/plain"
        ["file_path"]=> string(35) "/usr/local/var/www/Test/ci/uploads/"
        ["full_path"]=> string(43) "/usr/local/var/www/Test/ci/uploads/test.txt"
        ["raw_name"]=> string(4) "test"
        ["orig_name"]=> string(8) "test.txt"
        ["client_name"]=> string(8) "test.txt"
        ["file_ext"]=> string(4) ".txt"
        ["file_size"]=> float(0.01)
        ["is_image"]=> bool(false)
        ["image_width"]=> string(0) ""
        ["image_height"]=> string(0) ""
        ["image_type"]=> string(0) ""
        ["image_size_str"]=> string(0) ""
    }
    [1]=> array(14) {
        ["file_name"]=> string(9) "test2.txt"
        ["file_type"]=> string(10) "text/plain"
        ["file_path"]=> string(35) "/usr/local/var/www/Test/ci/uploads/"
        ["full_path"]=> string(44) "/usr/local/var/www/Test/ci/uploads/test2.txt"
        ["raw_name"]=> string(5) "test2"
        ["orig_name"]=> string(9) "test2.txt"
        ["client_name"]=> string(9) "test2.txt"
        ["file_ext"]=> string(4) ".txt"
        ["file_size"]=> float(0.01)
        ["is_image"]=> bool(false)
        ["image_width"]=> string(0) ""
        ["image_height"]=> string(0) ""
        ["image_type"]=> string(0) ""
        ["image_size_str"]=> string(0) ""
    }
}

When I use print_r(), I find it more useful to use it like this:
Code:
echo '<pre>',print_r($arr),'</pre>';

Then the output is a lot more readable. You can do the same with var_dump(), but it's a little less readable.
#17

[eluser]RaGe10940[/eluser]
Okay sorry,

I the issue now is that I need to take ["full_path"] from the array and attach that.

And i keep failing at doing that. I keep getting NULL from

Code:
var_dump($file);
#18

[eluser]TheFuzzy0ne[/eluser]
get_multi_upload_data() accepts no arguments. It returns an array (just like the one your posted above), containing the data for each uploaded file.

You should enable error reporting, then you'll see that you're accessing a non-existent array index. At the top of your index.php file, paste this:
Code:
ini_set('display_errors', '1');
error_reporting(E_ALL);

That should help you out a bit.
#19

[eluser]RaGe10940[/eluser]
I'm an idiot...

Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined index: full_path

Filename: controllers/email_controller.php

Line Number: 67

I had forgot that I turned it on to Production and didnt go back to development...

line 67 :

$file = $return["full_path"];

But the problem is though (that I don't understand)

is that the array is there. The array is defined as :

Code:
["full_path"]=> string(43) "/usr/local/var/www/Test/ci/uploads/test.txt"
Code:
["full_path"]=> string(44) "/usr/local/var/www/Test/ci/uploads/test2.txt"

is there? I just don't understand.
#20

[eluser]TheFuzzy0ne[/eluser]
No, it's not there. Smile

The array you're get back is an array of arrays, so:

Code:
$file1_path = $file[0]['full_path']; // Yaaay!
// and
$file2_path = $file[1]['full_path']; // RAWR!

$file3_path = $file['full_path'] // WRONG! Non-existent index.

Since we have an array of arrays, let's loop through them (just for demonstration purposes):
Code:
foreach ($return as $info)
{
    echo '<pre>',print_r($info),'</pre>';
}

You'll notice that TWO arrays are being output (one for each uploaded file), not one. Both of these arrays are contained within another array. Does that make sense? If not, I'm gonna have to show you what RaGe10940, really is! Tongue




Theme © iAndrew 2016 - Forum software by © MyBB