excel - Get image from local path in php -
i working on bulk upload project using excel sheet , using cakephp 3.2 writing application.
i have excel sheet column give image uploaded.
user have 3 choices go either
- upload images pre defined directory before bulk upload , give name of image in cell , image automatically selected path.
- give url of image (http://website/path/image.jpg)
- give path of image if on local machine. ex., c:\user\pictures\image.jpg if windows, , /home/user/picture/image.jpg if linux
this i'm doing save images
$p_image = $objworksheet->getcellbycolumnandrow(30, $row)->getvalue(); if (filter_var($p_image, filter_validate_url)) { // image url $full_image_path = $p_image; } else { // image folder $path = configure::read('media.bulkupload.pre.product'); // full path of image root directory $full_image_path = $path . ds . $p_image; } $upload_path = configure::read('media.upload') . ds . 'files' . ds; // new name of image $img_new_name = uniqid('img_').round(microtime(true) * 1000).rand(1,100000); if ($full_image_path) { // generate uuid directory name $dir = text::uuid(); // create new directory mkdir($upload_path.$dir, 0777, true); // save file try { $img = new \abeautifulsite\simpleimage($full_image_path); // save image of original size $img->best_fit(850,1036)->save($upload_path.$dir.'/'.$img_new_name.'.jpg'); } catch(exception $e) { echo 'error: '.$e->getmessage(); } }
image upload using url , pre ftp upload working fine. but, how image path of local system , save them.
you can't without users uploading image themselves. cannot retrieve file client's filesystem external server run php.
Comments
Post a Comment