Parcourir la 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 il y a 16 ans
Parent
révision
ff6e92dfc8
1 fichiers modifiés avec 15 ajouts et 4 suppressions
  1. +15
    -4
      caca-php/examples/www/img2txt.php

+ 15
- 4
caca-php/examples/www/img2txt.php Voir le fichier

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

global $file, $filename;

if((! $file) && ($argc == 2) && ($argv[1] == 'logo-caca.png'))
{
$file = 'logo-caca.png';
$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]);
usage($argc, $argv);


Chargement…
Annuler
Enregistrer