September 13, 201115 yr Hello, over the past few days, i have been coding a script which uploads an excel file and adds each of the rows to the database. i was wondering if there was a way to batch upload images files with names like rowid-nameoffile.jpg, so that php reads the row id at the start of the image name and then adds it to an entry for that row. is there anyway to do this while the excel file is being added to the database? Thanks Edited September 13, 201115 yr by Jaymul
September 14, 201115 yr Hello, over the past few days, i have been coding a script which uploads an excel file and adds each of the rows to the database. i was wondering if there was a way to batch upload images files with names like rowid-nameoffile.jpg, so that php reads the row id at the start of the image name and then adds it to an entry for that row. is there anyway to do this while the excel file is being added to the database? Thanks Hi Jaymul, Sure this is possible, just upload the files via FTP to a specific folder on your server then write into your script a check for related image files in that folder each time it adds a row. You can use pattern matching functions such as preg_match to match the wildcards in the imagename and if you find a matching image then perform whatever action you want (store that images name in your database/copy the file to another location etc). Cheers! Dave
September 14, 201115 yr Author Hi Jaymul, Sure this is possible, just upload the files via FTP to a specific folder on your server then write into your script a check for related image files in that folder each time it adds a row. You can use pattern matching functions such as preg_match to match the wildcards in the imagename and if you find a matching image then perform whatever action you want (store that images name in your database/copy the file to another location etc). Cheers! Dave thank you for your reply. i understand i could do this by using the explode function such as $picname = "0001-piece2.jpg"; $pieces = explode("-", $picname); foreach (array($pieces) as $value){ echo $value[0]; // Prints 0001 } but i wondered how i would use this while in a loop for upload and processing the images any ideas?
Create an account or sign in to comment