Browse Source

allow a filename exactly matching the uploaded filename; give a better

error message when this does not work
tags/v0.99.beta17
Ben Wiley Sittler bsittler 16 years ago
parent
commit
ff6e92dfc8
1 changed files with 15 additions and 4 deletions
  1. +15
    -4
      caca-php/examples/www/img2txt.php

+ 15
- 4
caca-php/examples/www/img2txt.php View File

@@ -30,7 +30,7 @@ $filename = isset($_FILES['file']) ? $_FILES['file']['name'] : NULL;
$args = NULL; $args = NULL;
if(isset($_REQUEST['args'])) if(isset($_REQUEST['args']))
{ {
$args = $_REQUEST['args'];
$args = trim($_REQUEST['args']);
if(strlen($args)) if(strlen($args))
{ {
foreach(explode(' ', $args) as $arg) foreach(explode(' ', $args) as $arg)
@@ -267,6 +267,7 @@ function version()
} }
function main() function main()
{ {
global $file, $filename;
global $argc, $argv; global $argc, $argv;
global $stderr; global $stderr;
$cols = 0; $cols = 0;
@@ -349,15 +350,25 @@ function main()
return 2; return 2;
} }


global $file, $filename;

if((! $file) && ($argc == 2) && ($argv[1] == 'logo-caca.png')) if((! $file) && ($argc == 2) && ($argv[1] == 'logo-caca.png'))
{ {
$file = 'logo-caca.png'; $file = 'logo-caca.png';
$argc = 1; $argc = 1;
} }
else if($filename && $file && ($argc == 2)
&&
(strtolower(basename($argv[1])) == strtolower(basename($filename))))
{
$argc = 1;
}

if($argc == 2)
{
$stderr .= sprintf("%s: image not found\n", $argv[1]);
return 1;
}


if($argc > 1)
if($argc > 2)
{ {
$stderr .= sprintf("%s: too many arguments\n", $argv[0]); $stderr .= sprintf("%s: too many arguments\n", $argv[0]);
usage($argc, $argv); usage($argc, $argv);


Loading…
Cancel
Save