Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is php rename() corrupting my file?
    text
    copied!<p>I am using plupload to do an upload of multiple files to my server. Using this, there is a parameter 'url : 'upload.php'. upload.php catches the files as they are received, and might recombine them if they get chunked. Once the full file is received, it sends a response back to the original page, displaying a green checkbox icon.</p> <p>I have added some code to this page, after all the main code to manipulate the photos I have uploaded. My plan is to create three copies of my full size image, lg, med, and small. I got this part working, but then decided to first rename the original file to match my naming scheme.</p> <p>I now get a corrupted renamed file, and thus my three smaller images also get corrupted.</p> <pre><code>//get the original file info $filepath = $_SERVER['DOCUMENT_ROOT'].'/uploads/'; $filepathinfo = pathinfo($filepath.$fileName);//fileName is used previously in the file //rename original file to a unique name $finding_id = 'xyz'; $file_name_new = uniqid($client_id . '-' . $finding_id . '-', true); //doesn't include extension //rename($filepath.$fileName, $filepath.$file_name_new.'.'.$ext); //copy($filepath.$fileName, $filepath.$file_name_new.'.'.$ext); </code></pre> <p>As is, I get my one file, or how ever many I uploaded, byte size matches original exactly, and name stays the same (except for removal of certain characters).</p> <p>If I uncomment only the rename function, I actually get two files. The byte sizes total the original photo. The larger file displays with a section of gray at the bottom. The smaller file doesn't display at all.</p> <p>If I uncomment only the copy function, I get an exact renamed copy of my original file, my original file, and another file, the same size and corruption as the larger file doing a rename.</p> <p>Any ideas? Seems like it should be pretty straightforward.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload