ajax - PHP upload files to server script doesnt upload everything -
i'm using php , ajax upload files server, can upload txt files, images, docs, zips,pdf... uploaded pdf of size 15mb when tried upload txt size 14mb script crashed here code
<form id="form" action="db/upload.php" method="post" enctype="multipart/formdata"> <input type="file" name="filetoupload" id="file">\ <input type="submit" value="upload image" name="submit" id="">\ </form>
javascript
//click event upload new file button $('#edit_window .file_container').on('submit', '#form', function(e) { e.preventdefault(); //code uploading file //get file data var file_data = $("#file").prop("files")[0]; var form_data = new formdata(this); form_data.append('file', file_data); form_data.append('link', id); $.ajax({ type: 'post', url: 'db/upload.php', data:form_data, cache: false, contenttype: false, processdata: false, success: function (data) { console.log(data); // $("#feedback").html(data); } }); });
php
<?php session_start(); //prevent running script if no 1 logged in if(!isset($_session["currentuser"])) exit(); $link = $_post['link']; $target_path = "../data/".$link."/"; $target_path = $target_path . basename( $_files[ 'filetoupload' ][ 'name' ] ); if ( move_uploaded_file( $_files[ 'filetoupload' ][ 'tmp_name' ] , $target_path ) ){ echo "upload complete!"; } else { echo "error uploading!"; } ?>
user.ini
upload_max_filesize = 40m post_max_size = 40m max_execution_time = 10000 max_input_time = 10000
javascript output
<br /> <font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'> <tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> notice: undefined index: filetoupload in c:\wamp\www\elmar\db\upload.php on line <i>8</i></th></tr> <tr><th align='left' bgcolor='#e9b96e' colspan='5'>call stack</th></tr> <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>time</th><th align='left' bgcolor='#eeeeec'>memory</th><th align='left' bgcolor='#eeeeec'>function</th><th align='left' bgcolor='#eeeeec'>location</th></tr> <tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0020</td><td bgcolor='#eeeeec' align='right'>245888</td><td bgcolor='#eeeeec'>{main}( )</td><td title='c:\wamp\www\elmar\db\upload.php' bgcolor='#eeeeec'>..\upload.php<b>:</b>0</td></tr> </table></font>
Comments
Post a Comment