I am using the Uploadify Plugin to upload the picture, and i am doing some operations like
a) when a user upload the file the upload button is removed automatically b) and the uploadify.php script will rename the file and store it in designated directory.
and here is the code which i am using to perform the action.
Jquery Code :
<script type="text/javascript"> $(document).ready(function() { $('#fileUpload, #fileUpload2').uploadify({ 'uploader': 'img/uploadify.swf', 'script': 'uploadify.php', 'folder': 'upload', 'auto' : 'true', 'cancelImg': 'img/cancel.png', 'fileDesc': 'jpg/jpeg', 'displayData': 'percentage', 'fileExt': "*.jpg;*.jpeg", 'sizeLimit' : '8388608', 'fileDataName' : 'file', onComplete : function(event, queueID, fileObj, reposnse, data) { $('#filesUploaded').append('<a href='+fileObj.filePath+'>'+fileObj.name+'</a><br>'); $("#firstUpload").remove(); } }); }); </script> and in the php i have used the combination of date with a unique id to rename the file which is perfectly working fine.
but when i want to view the file name and i do that by calling the div
<div id="filesUploaded"></div> it shows the original filename and not the renamed file. i tried changing the value from '+fileObj.name+' to '+response+'
i guess the problem is within the above code as the file.Obj.name prints the selected file name and not the processed file, and when i change it to +response+ it uploads the file and rename it but in the form page it does not print the renamed file name. and it freezes with the progress bar composing 100% progress.
how do i make it print the renamed file name.?
thank you
Edit : here is my PHP code .
<?php include('database.php'); $date = date("dFY"); $query = "SELECT MAX(id) as max_id FROM news"; $result = mysql_query($query); $row = mysql_fetch_array($result); $max_id = $row['max_id']+1; echo $max_id; $file1 = "file_$date"."_$max_id.jpg"; if (!empty($_FILES)) { $tempFile = $_FILES['file']['tmp_name']; $targetPath = 'upload/'; move_uploaded_file($tempFile,$targetPath.$file1); } ?>