Uploadify not uploading file, but indicates success

I found several posts with the same problem as mine, but no solutions were provided. I am not 100% sure what to do with this, but I hope you can help.

I am trying to use Uploadify to upload files, but the following happens:

  • Viewing the file successfully (hence my script and loaded attributes) is correct.
  • The progress bar says โ€œ100%โ€ and ends.
  • onComplete fires, saying that the download is successful (according to the path warning, the "folder" attribute is correct.)
  • If I die my script before any exit, step # 3 will not happen - therefore, it will reach the specified script '. After the output, the script does not die.
  • FILE NOT FOUND IN FILESYSTEM

I donโ€™t know how this is possible - as far as I can tell, everything is correct.

Here is my code:

<script type="text/javascript"> $(document).ready(function() { $("#addimage").validationEngine(); $('#imagefile').uploadify({ 'uploader': "/js/uploadify/uploadify.swf", 'fileExt': "*.jpg;*.jpeg;*.png;*.gif", 'buttonText': "Browse...", 'script': "/js/uploadify/uploadify.php", 'cancelImg': "/js/uploadify/cancel.png", 'folder': "/uploads", 'fileDesc': 'Only *.jpg, *.jpeg, *.png, *.gif are allowed', 'auto': true, 'onComplete': function(event, ID, fileObj, response, data) { $('#name').val('Please edit this text to add a description...'); alert('Uploaded ' + fileObj.name + ' to ' + fileObj.filePath + '.'); } }); }); </script> <input type="file" id="imagefile" name="imagefile" /> <?php if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/'; $targetFile = str_replace('//', '/', $targetPath) . 'image_' . date('YmdHis') . '_' . $_FILES['Filedata']['name']; move_uploaded_file($tempFile,$targetFile); echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile); } ?> 

The only change to the PHP script is the name targetFile, which I changed to provide some kind of unique file name (albeit not reliable), but otherwise the script will be the same as the released one (with comments removed here for brevity).

Can someone tell me why Uploadify indicates that the file upload was successful, but the file does not exist in the uploads directory? I use Windows, PHP5.3, and the uploads folder is writable (I can upload files there without Uploadify, but not with it)

Thanks in advance!

Cobus

+6
upload uploadify
source share
1 answer

I had similar problems on a Linux machine. It turned out that the PHP configuration on my server was cuplrit. PHP worked in SAFE MODE. Since I uploaded Uploadify scripts via FTP, the script files were saved on the file system with my FTP user data. Since the PHP temp folder belonged to the root server, I had a UID mismatch, i.e. The temporary download file was attributed to root, and the download script that tried to move it belonged to the FTP user. It broke him.

To solve this problem, I changed the permissions to upload the php script to root and from that moment it worked.

0
source share

All Articles