I am trying to implement a file upload to a pre-existing form that I know works, and still does aside from the file upload section.
Essentially, I am unsure of the error and how to fix it. The outputs are only what I have put in there based on my understanding of the code
I get the following output from the below code:
OUTPUT
Array ( [chart-image] => Array ( [name] => Chart example.jpg [type] => image/jpeg [tmp_name] => /tmp/php5iGbQD [error] => 0 [size] => 50222 ) ) CAN'T MOVE FILE
FORM
<form id="<?php echo $type ?>-trade" enctype="multipart/form-data" method='post' action='<?php echo $url; ?>'>
*snip*
<input type="hidden" name="MAX_FILE_SIZE" value="52428800" />
<input name="chart-image" type="file" />
*snip*
</form>
ACTION PAGE
snip print_r($_FILES);if($_FILES['chart-image']['error'] == '0'){ $uploaddir = '/images/charts/'; $file = basename($_FILES['chart-image']['name']); $uploadfile = $uploaddir . $file; if(file_exists($_FILES['chart-image']['tmp_name'])){ if (move_uploaded_file($_FILES['chart-image']['tmp_name'], $uploadfile)) { echo "GOOD"; } else { echo "CAN'T MOVE FILE"; } } else { echo "ERROR"; } } else{ echo "Error In Uploading File"; } *snip*
Additional Info
- I am running wordpress
- Folder is chmod 777
- Upload forms enabled in
php.ini
- File is smaller than max filesize in both
<form>
andphp.ini
error_reporting(E_ALL); ini_set('display_errors', true);
This should give you a warning about what went wrong. - deceze