使用md5上传后正确获取文件

时间:2015-07-21 23:07:21

标签: php hash upload opencart md5

以下是OpenCart的upload.php中代码的一部分:

Jul 22, 2015 11:48:57 PM org.springframework.integration.handler.LoggingHandler handleMessageInternal
SEVERE: java.lang.NoClassDefFoundError: Could not initialize class org.jdom2.input.sax.XMLReaders
    at com.rometools.rome.io.WireFeedInput.createSAXBuilder(WireFeedInput.java:306)
    at com.rometools.rome.io.WireFeedInput.build(WireFeedInput.java:207)
    at com.rometools.rome.io.SyndFeedInput.build(SyndFeedInput.java:133)
    at com.rometools.fetcher.impl.HttpURLFeedFetcher.readSyndFeedFromStream(HttpURLFeedFetcher.java:300)
    at com.rometools.fetcher.impl.HttpURLFeedFetcher.getSyndFeedFromStream(HttpURLFeedFetcher.java:306)
    at com.rometools.fetcher.impl.HttpURLFeedFetcher.resetFeedInfo(HttpURLFeedFetcher.java:217)
    at com.rometools.fetcher.impl.HttpURLFeedFetcher.retrieveAndCacheFeed(HttpURLFeedFetcher.java:188)
    at com.rometools.fetcher.impl.HttpURLFeedFetcher.retrieveFeed(HttpURLFeedFetcher.java:140)
    at com.rometools.fetcher.impl.HttpURLFeedFetcher.retrieveFeed(HttpURLFeedFetcher.java:99)
    at org.springframework.integration.feed.inbound.FeedEntryMessageSource.getFeed(FeedEntryMessageSource.java:204)
    at org.springframework.integration.feed.inbound.FeedEntryMessageSource.populateEntryList(FeedEntryMessageSource.java:182)
    at org.springframework.integration.feed.inbound.FeedEntryMessageSource.doReceive(FeedEntryMessageSource.java:157)
    at org.springframework.integration.feed.inbound.FeedEntryMessageSource.receive(FeedEntryMessageSource.java:122)
    at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:144)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:192)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:55)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:149)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:146)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:298)
    at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52)
    at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
    at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:49)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:292)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
    at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

/usr/share/tomcat7/bin/catalina.sh stop
Jul 22, 2015 11:49:02 PM org.springframework.integration.handler.LoggingHandler handleMessageInternal
SEVERE: java.lang.NoClassDefFoundError: Could not initialize class org.jdom2.input.sax.XMLReaders
    at com.rometools.rome.io.WireFeedInput.createSAXBuilder(WireFeedInput.java:306)
    at com.rometools.rome.io.WireFeedInput.build(WireFeedInput.java:207)
    at com.rometools.rome.io.SyndFeedInput.build(SyndFeedInput.java:133)
    at com.rometools.fetcher.impl.HttpURLFeedFetcher.readSyndFeedFromStream(HttpURLFeedFetcher.java:300)
    at com.rometools.fetcher.impl.HttpURLFeedFetcher.getSyndFeedFromStream(HttpURLFeedFetcher.java:306)
    at com.rometools.fetcher.impl.HttpURLFeedFetcher.resetFeedInfo(HttpURLFeedFetcher.java:217)
    at com.rometools.fetcher.impl.HttpURLFeedFetcher.retrieveAndCacheFeed(HttpURLFeedFetcher.java:188)
    at com.rometools.fetcher.impl.HttpURLFeedFetcher.retrieveFeed(HttpURLFeedFetcher.java:140)
    at com.rometools.fetcher.impl.HttpURLFeedFetcher.retrieveFeed(HttpURLFeedFetcher.java:99)
    at org.springframework.integration.feed.inbound.FeedEntryMessageSource.getFeed(FeedEntryMessageSource.java:204)
    at org.springframework.integration.feed.inbound.FeedEntryMessageSource.populateEntryList(FeedEntryMessageSource.java:182)
    at org.springframework.integration.feed.inbound.FeedEntryMessageSource.doReceive(FeedEntryMessageSource.java:157)
    at org.springframework.integration.feed.inbound.FeedEntryMessageSource.receive(FeedEntryMessageSource.java:122)
    at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:144)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:192)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:55)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:149)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:146)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:298)
    at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52)
    at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
    at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:49)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:292)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
    at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

对于编码 $file = $filename . '.' . md5(mt_rand()); move_uploaded_file($this->request->files['file']['tmp_name'], DIR_UPLOAD . $file); // Hide the uploaded file name so people can not link to it directly. $this->load->model('tool/upload'); $json['code'] = $this->model_tool_upload->addUpload($filename, $file); ,它将插入如下数据:

enter image description here

字段'代码'由编码'$this->model_tool_upload->addUpload($filename, $file)'生成。

新文件将插入文件夹:

enter image description here

我想上传图片然后显示它。在这种情况下,如何使用PHP正确获取文件路径?

此外,有人可以解释为什么文件名附加了md5字符串?它是否仅用于隐藏上传的文件名以及字段'代码'用于?

更新

只需在源文件中找到答案:

'sha1(uniqid(mt_rand(), true))'

0 个答案:

没有答案