Image upload using uploadify |
[eluser]mostafash[/eluser]
Hi , I want use uploadify to upload images to my server with codeigniter and my codes is this: View form: <code> <form acti method="post"> <div id="queue"></div> <input id="file_upload" name="file_upload" type="file" multiple="true"> </form> [removed] <?php $timestamp = time();?> $(function() { $('#file_upload').uploadify({ 'formData' : { 'timestamp' : '<?php echo $timestamp;?>', 'token' : '<?php echo md5('unique_salt' . $timestamp);?>' }, 'swf' : '<?php echo base_url(); ?>images/admin/uploadify.swf', 'uploader' : '<?php echo base_url(); ?>admin/uploadify' }); }); [removed] </code> uploadify function in my controller: <code> public function uploadify(){ $this->File_model->uploadify(); } </code> And my model function : <code> public function uploadify(){ $targetFolder = base_url().'uploads/images/'; // Relative to the root $verifyToken = md5('unique_salt' . $_POST['timestamp']); $targetPath = $targetFolder; //echo $targetFile = rtrim($targetPath,'/') . '/' ;die(); if (!empty($_FILES) && $_POST['token'] == $verifyToken) { $tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = $targetFolder; $targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name']; // Validate the file type $fileTypes = array('jpg','jpeg','gif','png'); // File extensions $fileParts = pathinfo($_FILES['Filedata']['name']); if (in_array($fileParts['extension'],$fileTypes)) { move_uploaded_file($tempFile,$targetFile); echo '1'; } else { echo 'Invalid file type.'; } } } </code> This is my code , It's work but didn't upload anything ![]() and this is uloader link : http://www.uploadify.com/demos/
[eluser]TheFuzzy0ne[/eluser]
Have you tried installing the Firebug extension for Firefox? It can help you see what's going on with regards to communication between the client and server. I seem to remember that I had a problem with the session, and ended up having to send the encrypted session cookie with the request in order to make it work. |
Welcome Guest, Not a member yet? Register Sign In |