0

名前付きの画像をアップロードして#includedいますが、画像が表示されません。

たとえば、ファイル名を作成した場合、5677PlayadelRey,#4_LR.jpg Joomla のファイルシステムはそれをロードできませんが、名前を付けると正常に動作5677PlayadelRey,Unit4_LR. jpgしました。

よろしくお願いします。

4

6 に答える 6

1

urlencodeファイル名が URL に対して安全であることを確認するために使用できます。

http://php.net/manual/en/function.urlencode.php

これは、URL でファイル名を使用する必要がある場合にのみ使用できます。ファイル名は好きなように保持できます。

于 2013-02-20T04:53:41.230 に答える
1

これは、#文字がページのハッシュ/ID を指定するためです。URL 内で使用できない文字です。

カンマ,も URL 内にあってはならないものです

于 2013-02-20T04:51:39.323 に答える
0

画像を処理しているメソッドでは、次のようになります。

jimport('joomla.filesystem.file');
$input = JFactory::getApplication()->input;

次に、

$your_photo_name = JFile::makeSafe($input->get('your_photo_name');

これにより、ファイル名がJoomla!で安全に使用できるようになります。システム

于 2013-02-20T09:41:09.537 に答える
0

これを試してください

<?php
    // define a constant for the maximum upload size
    define ('MAX_FILE_SIZE', 1024 * 50);

    if (array_key_exists('upload', $_POST)) {
      // define constant for upload folder
      define('UPLOAD_DIR', '/path/to/images/');
      // replace any spaces in original filename with underscores
      $file = str_replace('#', '_', $_FILES['image']['name']);
      // create an array of permitted MIME types
      $permitted = array('image/gif', 'image/jpeg', 'image/pjpeg',
    'image/png');

      // upload if file is OK
      if (in_array($_FILES['image']['type'], $permitted)
          && $_FILES['image']['size'] > 0 
          && $_FILES['image']['size'] <= MAX_FILE_SIZE) {
        switch($_FILES['image']['error']) {
          case 0:
            // check if a file of the same name has been uploaded
            if (!file_exists(UPLOAD_DIR . $file)) {
              // move the file to the upload folder and rename it
              $success =
    move_uploaded_file($_FILES['image']['tmp_name'], UPLOAD_DIR .
    $file);
            } else {
              $result = 'A file of the same name already exists.';
            }
            if ($success) {
              $result = "$file uploaded successfully.";
            } else {
              $result = "Error uploading $file. Please try again.";
            }
            break;
          case 3:
          case 6:
          case 7:
          case 8:
            $result = "Error uploading $file. Please try again.";
            break;
          case 4:
            $result = "You didn't select a file to be uploaded.";
        }
      } else {
        $result = "$file is either too big or not an image.";
      }
    }
    ?>
于 2013-02-20T05:14:08.653 に答える
0

#は URL で渡されないので、何でも使用してください#

于 2013-02-20T04:53:57.150 に答える
0

Joomla を使用している場合は、すべてのファイル名を英数字 + アンダースコアにする必要があります。インストールするプラグインの多くは、この仮定に基づいている可能性があります。そうしないと、物事が壊れる可能性があります。

于 2013-02-20T05:14:52.117 に答える