jQuery file upload이라는 플러그인을 사용하여 이미지를 페이지에 업로드하고 있습니다. 현재 원본 이미지 이름을 파일 이름 (IMG_1234
)으로 업로드합니다. jQuery 파일 업로드 'undefined'이미지 URL
class CustomUploadHandler extends UploadHandler
{
protected function trim_file_name($name, $type) {
$name = time()."_1";
$name = parent::trim_file_name($name, $type);
return $name;
}
}
나는 이미지를 업로드
이 올바르게 이름 : 나는 서버에 이미지 이름에 특정 형식이 필요합니다 (예 :1.123456.jpg
)
나는 이미지 이름을 변경하는 작업이 PHP 코드를 발견 이미지 미리보기 링크는 undefined
입니다. 이렇게하면 플러그인을 통해 이미지를 삭제할 수 없습니다.
변수 data.url
은 undefined
입니다 ... 이미지의 이름을 바꾸지 않는 원래 코드로 돌아 가면 모든 것이 잘됩니다.
누군가이 도움이 될 수있는이 플러그인에 대한 경험이 있습니까? 감사!
편집 :
나는 (또한 삭제에 사용되는) 다운로드 링크를 반환하는 기능은 원본 파일 이름이 아닌 업데이트를주고있다 적어도 문제의 일부를 발견했습니다. 필자는 PHP 클래스를 처음 접했으므로 변수가 어디에서 유래되었으며 어떻게 수정해야하는지 잘 모릅니다. 내가 얻을 수있는 어떤 도움에 정말로 감사드립니다!
protected function get_download_url($file_name, $version = null, $direct = false) {
if (!$direct && $this->options['download_via_php']) {
$url = $this->options['script_url']
.$this->get_query_separator($this->options['script_url'])
.'file='.rawurlencode($file_name);
// The `$file_name` variable is the original image name (`IMG_1234`), and not the renamed file.
if ($version) {
$url .= '&version='.rawurlencode($version);
}
return $url.'&download=1';
}
if (empty($version)) {
$version_path = '';
} else {
$version_url = @$this->options['image_versions'][$version]['upload_url'];
if ($version_url) {
return $version_url.$this->get_user_path().rawurlencode($file_name);
}
$version_path = rawurlencode($version).'/';
}
return $this->options['upload_url'].$this->get_user_path()
.$version_path.rawurlencode($file_name);
}
편집 2 :
여기에 해당 기능의 PHP 코드의 나는 옵션에 'param_name' => 'files',
함께 할 수있는 뭔가가 생각합니다. 누구는 그것이 무엇을하는지 압니까?