Welcome Guest, Not a member yet? Register   Sign In
Image upload using uploadify
#1

[eluser]mostafash[/eluser]
Hi ,
I want use uploadify to upload images to my server with codeigniter
and my codes is this:
View form:
<code>
&lt;form acti method="post"&gt;
<div id="queue"></div>
&lt;input id="file_upload" name="file_upload" type="file" multiple="true"&gt;
&lt;/form&gt;
[removed]
&lt;?php $timestamp = time();?&gt;
$(function() {
$('#file_upload').uploadify({
'formData' : {
'timestamp' : '&lt;?php echo $timestamp;?&gt;',
'token' : '&lt;?php echo md5('unique_salt' . $timestamp);?&gt;'
},
'swf' : '&lt;?php echo base_url(); ?&gt;images/admin/uploadify.swf',
'uploader' : '&lt;?php echo base_url(); ?&gt;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 Sad
and this is uloader link :
http://www.uploadify.com/demos/
#2

[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.




Theme © iAndrew 2016 - Forum software by © MyBB