Commit 356cc4a7 authored by hancong03's avatar hancong03

修复不能自动创建路径的问题

Signed-off-by: 's avatarhancong03 <hancong03@baidu.com>
parent f33de2ea
<?php
return array(
'savepath' => dirname( __FILE__ ) . '/upload/'
);
\ No newline at end of file
......@@ -27,7 +27,9 @@ class FreeMindParser {
'topic' => $data
) );
$filepath = getcwd() . '/upload/' . $data[ 'meta' ][ 'id' ] . '.mm';
$savepath = self::getSavePath();
$filepath = $savepath . '/' . $data[ 'meta' ][ 'id' ] . '.mm';
file_put_contents( $filepath, $content );
return $filepath;
......@@ -72,6 +74,19 @@ class FreeMindParser {
}
private static function getSavePath () {
$config = require( dirname(__FILE__) . '/../config.php' );
$savepath = $config[ 'savepath' ];
if ( !file_exists( $savepath ) ) {
mkdir( $savepath, 0770, true );
}
return pathinfo( $savepath . '/test', PATHINFO_DIRNAME );
}
private static function getTimeAndId () {
$timestamp = intval( microtime( true ) * 1000 );
......
......@@ -163,9 +163,7 @@ class XMindParser {
$info = self::getTimeAndId();
$imagePath = getcwd() . '/tmp/' . $info[ 'id' ] . $image[ 'suffix' ];
rename( $image[ 'filepath' ], $imagePath );
$imagePath = $image[ 'filepath' ];
$source['data'][ 'image' ] = array(
'filepath' => 'attachments/' . $info[ 'id' ] . $image[ 'suffix' ],
......@@ -173,12 +171,12 @@ class XMindParser {
);
array_push( $attachments, array(
$attachments[] = array(
'filepath' => 'attachments/' . $info[ 'id' ] . $image[ 'suffix' ],
'origin' => $imagePath,
'type' => $image[ 'mime' ],
'meta' => $info
) );
);
}
......@@ -200,7 +198,16 @@ class XMindParser {
private static function move ( $meta, $path ) {
$filepath = getcwd() . '/upload/' . $meta['id'] . '.xmind';
$config = require( diranme( __FILE__ ) . '/../config.php' );
$savepath = $config[ 'savepath' ];
if ( !file_exists( $savepath ) ) {
mkdir( $savepath, 0770, true );
}
$savepath = pathinfo( $savepath . '/test', PATHINFO_DIRNAME );
$filepath = $savepath . '/' . $meta['id'] . '.xmind';
rename( $path, $filepath );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment