Why is my PHP upload script not working?

Posted by Turner on Stack Overflow See other posts from Stack Overflow or by Turner
Published on 2011-02-28T23:16:12Z Indexed on 2011/02/28 23:25 UTC
Read the original article Hit count: 237

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about php

Related posts about html