0

I am trying to upload a file through a custom form into WordPress directory but not able to upload it. My code is:

<input type="file" name="attachment">


<?php
$uploaddir= '/home/a796f80a/induri.com/attachment/';
$attachment=$uploaddir.basename($_FILES['attachment']['name']);
move_uploaded_file($_FILES['attachment']['tmp_name'], $attachment);
?>

the error I am getting: Array ( [attachment] => Array ( [name] => testfile.txt [type] => text/plain [tmp_name] => /tmp/phpGZYCbR [error] => 0 [size] => 0 ) )

2
  • Hello @shashank - Welcome to the WordPress Development community! Your question will receive higher quality answers if you elaborate further on the problem you're experiencing - consider adding how you know it doesn't work, any errors you've encountered, and the steps you've tried to troubleshoot it. It also looks like some other necessary information might be missing - how do you submit this custom form? Where is the code you've posted located in your WordPress installation? Take a minute to review the "How to Ask" page in our help center for more guidance.
    – bosco
    Commented May 26, 2018 at 17:57
  • Maybe it's obvious but.. first of all check the permission of the folder you want to upload the file to Commented May 29, 2018 at 7:16

1 Answer 1

0

May I know what plugin you are using for Uploading the File? If you are using the current version of php & cPanel, And have your WordPress to the latest version, I recommend you using the CALDERA FORMS. Here is the Link: https://wordpress.org/plugins/caldera-forms/

So next time you create for example a Job Application form with UPLOAD Button for uploading CV/Resume in .pdf or .docx format, any user can go to your Form Section and Upload the File. And you receive that notification via email that you provide during setting up the Form. ALL FIELDS ARE CUSTOM. You can a Do A Lot :) Thanks & Cheers

Let me know if it worked for you :) Team FlipSite

3
  • Hi there., I am not using any plugin.
    – shashank
    Commented May 26, 2018 at 11:29
  • Try using Caldera
    – FlipSite
    Commented May 26, 2018 at 11:30
  • Thank you. but i don't want to use any plugin
    – shashank
    Commented May 26, 2018 at 11:32

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.