Hey Rizwan,
I think what you are looking for, is the Media Service. So you can easily check if a product image/file exists and if necessary upload a new one.
Creating the correct paths takes over the service for you.
Create a folder via SFTP/FTP, e.g. “pdf”, “upload” or what ever.
Here is a small example for u:
$mediaService = Shopware()->Container()->get('shopware_media.media_service');
// Whatever u want do with the name
$_name = $_FILES['file']['name'];
$_file_content = file_get_contents($_FILES['file']['tmp_name']);
// Check
if($mediaService->has("media/pdf/$_name") === false){
// upload to media Folder in md5 Format
try {
$mediaService->write("media/pdf/$_name", $_file_content);
} catch(Exception $e) {
echo '';
print_r($e);
echo '';
exit;
}
}
.
..
when submit form it’s showing this error can you help me more please what should i do now and when i revoke the try case n var_dump $_file_content it show null