I want to modify and replace the upload image path
I want to modify and replace the upload image path
->setFormatter( Format::ifEmpty( null ) )
// ->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/uploads/__ID__.__EXTN__' )
->upload( Upload::inst('//192.168.0.7'.'/uploads/__ID__.__EXTN__' )
->db( 'files', 'id', array(
'filename' => Upload::DB_FILE_NAME,
'filesize' => Upload::DB_FILE_SIZE,
'web_path' => Upload::DB_WEB_PATH,
'system_path' => Upload::DB_SYSTEM_PATH
) )
->validator( Validate::fileSize( 500000, '图片大小不能超过500K' ) )
->validator( Validate::fileExtensions( array( 'png', 'jpg', 'jpeg', 'gif' ), "Please upload an image" ) )
),
I use to upload pictures. My pictures are stored under 192.168.0.7 and uploaded on the web database_ The storage path under path is: \ \ 192.168.0.7 \ upload \ 42.jpg, but I want to add 8098 after \ \ 10.0.8.9 ,and use substr_ Replace function is replaced with "\ \ 192.168.0.7:8098 \ upload \ 42. JPG". How do I rewrite this code?
Thanks
Error messages shown:
Description of problem:
This question has an accepted answers - jump to answer
Answers
It sounds like you'd need to provide a custom upload action.
Allan
Thanks allan
Yes, I started to upload with customization, but according to the example, the above code reports an upload error. I don't think it can store the web_ Path and system_ Path, how do I put the web_ Path and system_ Web path is stored in the files table of the database_ Path and system_ Path field。
Report: failed to load resource: the server responded with a status of 404 (not found)
Your function there is the same as if you were to do:
And that would then allow Editor to use its system and web path parameters.
Allan
It can be executed normally and uploaded without customization
Sorry - I'm not sure if that is a question, or an acknowledgement that the problem is now resolved with my last reply?
Allan
Allan,problem hasn't been solved yet. According to what you said, I want to use custom upload. At present, the code is as above, and there is no error, but the file hasn't been uploaded, and I don't know how to store the image path 'web_path' => '',
'system_path' => '' to files table, But fileName and filesize field already stored
If you want to use a custom upload action, you will need to update the database with the path information in that action function. For example:
Remember to add
use($db)
to your anonymous function.Allan
Thanks,