I got kinda weird problem, but hope someone knows what's the case.
I've cloned project from git and started to work with it in PHPStorm, ran it in my local Apache server. So it was working first time, but in my next try, script didn't response. restart Apache didn't help, as re-run script in IDE too. No any information in browser console/resources.
I've decided that this is a problem in headers, and re-wrote script:
$fileInputName = 'uploadedFile';
if ( !array_key_exists( $fileInputName, $_FILES ) ) {
echo ('there are no files to work with');
die();
}
$uploadName = $_FILES[$fileInputName]['tmp_name'];
$size = $_FILES[$fileInputName]['size'];
$pathToSaveSVG = realpath(dirname(__FILE__)) . '/SVG';
$fileName = $uploadName . '.pdf';
$targetName = $fileName . '.svg';
if ( !move_uploaded_file( $uploadName, $fileName ) ) {
echo ($uploadName. ' '. $fileName);
unlink( $uploadName );
echo( 'can\'t move uploaded file' );
die();
}
exec( 'pdf2svg ' . escapeshellarg( $fileName ) . ' ' . escapeshellarg( $pathToSaveSVG. '/' . $targetName ) );
unlink($fileName);
echo $pathToSaveSVG . '/' . $targetName;
die;
html:
<form action="pdf_to_svg.php" method="POST" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
<input type="file" name="uploadedFile" id="file" accept="application/pdf" />
<input type="submit" name="submit" value="Convert " />
</form>
Then, it repeats. Script works fine if i just take files to convert by name, not by POST data sending.
Please, any hints, why sending data via POST method crashes script on second time working? It looks like cyclic forwarding at server-side or something, but with no visible errors, and in apache logs too.
ADD: Looks like it relates to permissions. At first time, file uploads with error 3 - file have uploaded partially. I tried chmod 755 -R ./SVG
, no results. Could someone help me figure this out?