Why is my PHP upload script not working?
- by Turner
Hello all, I am doing some simple work with uploading a file. I am ignoring error checking and exceptions at this point just to get my uploads working. I have this HTML form:
<form action='addResult.php' method='post' enctype='multipart/form-data' target='results_iFrame' onsubmit='startUpload();'>
Entry: <input type='text' id='entry' />
Stop: <input type='text' id='stop' />
Final: <input type='text' id='final' />
Chart: <input type='file' id='chart' />
<input type='submit' value='Add' /></form>
As you can see, it calls 'addResult.php' within the iFrame 'results_iFrame'. The Javascript is just for animation purposes and to tell me when things are finished.
addResult.php has this code in it (along with processing the other inputs):
$upload_dir = "../img/";
$chart_loc = $upload_dir.basename($_FILES['chart']['name']);
move_uploaded_file($_FILES['chart']['tmp_name'], $chart_loc);
print_r($_FILES);
It uses the 'chart' input from the form and tries to upload it. I have the print_r() function to display some information on $_FILES, but the array is empty, thus making this fail. What could I be doing wrong?