php - uploadifive: uploading does not work, maybe it's a root issue? -
the past 6 days have been busy multiple file upload. found uploadify , tried free version. didn't work out bought uploadifive. still doesn't work out. if change nothing code , implement got it, doesn't upload file. don't errors, uploadbar goes 100%. , uploadfolder stays empty. have set chmod permissions 755 advised , tried 777. tried changing $_server['document_root'] . $targetfolder absolute path. when echo document_root gives /htdocs. doesn't matter in folder put it.
i'm losing mind on , don't know how solve this. below i've posted code index.php , uploadifive.php got after download:
index.php
<form> <div id="queue"></div> <input id="file_upload" name="file_upload" type="file" multiple="true"> <a style="position: relative; top: 8px;" href="javascript:$('#file_upload').uploadifive('upload')">upload files</a> </form> <script type="text/javascript"> <?php $timestamp = time();?> $(function() { $('#file_upload').uploadifive({ 'auto' : false, 'checkscript' : 'check-exists.php', 'formdata' : { 'timestamp' : '<?php echo $timestamp;?>', 'token' : '<?php echo md5('unique_salt' . $timestamp);?>' }, 'queueid' : 'queue', 'uploadscript' : 'uploadifive.php', 'onuploadcomplete' : function(file, data) { console.log(data); } }); }); </script>
uploadifive.php
// set uplaod directory $uploaddir = '/uploads/'; // set allowed file extensions $filetypes = array('jpg', 'jpeg', 'gif', 'png'); // allowed file extensions $verifytoken = md5('unique_salt' . $_post['timestamp']); if (!empty($_files) && $_post['token'] == $verifytoken) { $tempfile = $_files['filedata']['tmp_name']; $uploaddir = $_server['document_root'] . $uploaddir; $targetfile = $uploaddir . $_files['filedata']['name']; // validate filetype $fileparts = pathinfo($_files['filedata']['name']); if (in_array(strtolower($fileparts['extension']), $filetypes)) { // save file move_uploaded_file($tempfile, $targetfile); echo 1; } else { // file type wasn't allowed echo 'invalid file type.'; } }
does see problem here?
it $_server['document_root']. removing , replacing rootfolder did trick.
adjusted code:
// set upload directory $uploaddir = '/uploads/'; if (!empty($_files) && $_post['token'] == $verifytoken) { $tempfile = $_files['filedata']['tmp_name']; $uploaddir = '../htdocs'. $uploaddir; $targetfile = $uploaddir . $_files['filedata']['name'];
thanks :)
Comments
Post a Comment