1

I'm uploading my files to Amazon S3 and don't need to store them locally. Instead of using unlink() or cron jobs I want to add the files to the tmp folder and send them to Amazon S3 from there. I tried specifying the path in config options:

$tmp = ini_get('upload_tmp_dir');
$config['upload_path'] = $tmp;

and I get an upload error:

The upload destination folder does not appear to be writable.

I made my tmp folder writable and still get the error. Does anyone know how to upload just to tmp folder using the CI upload library? I'm afraid that I might have to modify the core upload library removing all upload path functions.

4
  • Why you can't use $_FILES['fieldname'][tmp_name] directly ? Commented Oct 13, 2012 at 18:34
  • that gets the filename. I need to specify the tmp folder. using /tmp/ in the filepath seems to work Commented Oct 13, 2012 at 18:41
  • You can' write tmp folder of server. you will get tmp file path in $_FILES['fieldname'][tmp_name] so when you upload any file it gets store into tmp folder that path you will get using $_FILES['fieldname'][tmp_name] and you can use this path to upload your file to Amzaon S3 Commented Oct 13, 2012 at 18:45
  • /tmp/ in path appears to work. I can get the filename using $this->upload->file_name and gives me the tmp_name. Commented Oct 13, 2012 at 18:47

1 Answer 1

5

ini_get() is a representation of php.ini.

If you open up php.ini you'll find that upload_tmp_dir is set to null

If you echo ini_get('upload_tmp_dir'); you'll probably notice that it won't - that's because it's null. Which means you're feeding an empty string into $config['upload_path'] and CodeIgniter will choose your document root by default.

Use sys_get_temp_dir() or simply '/tmp', instead.

Sign up to request clarification or add additional context in comments.

1 Comment

I know this is old...but it helped point me in the right direction. So thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.