Bonjour a tous , je suis arrivé a la fin de mon site
Mon probleme est assez simple, j'arrive a faire l'umpload d'image dans 3 classes differentes mais dans la classe producttype l'image ne s'affiche pas et dans la base de donnée je trouve qu'elle est sous : C:/wamp/tmp/phpFB11.tmp
et si je clique sur le l'image j'obtiens :
The requested URL /CRM/web/Products/Thmbn1/21/C:/wamp/tmp/phpFB11.tmp was not found on this server.
Ce que je n'arrive pas a comprendre c'est que le code est le meme
ci dessous l'entite producttype:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php
 
namespace Project\CRMBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
 
/**
 * Producttype
 *
 * @ORM\Table(name="producttype")
 * @ORM\Entity
 */
class Producttype
{
    /**
     * @var integer
     *
     * @ORM\Column(name="ID", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;
 
    /**
     * @var string
     *
     * @ORM\Column(name="PRODUCTTYPENAME", type="string", length=100, nullable=true)
     */
    private $producttypename;
 
    /**
     * @var string
     * @Assert\File( maxSize = "1024k", mimeTypesMessage = "Please upload a valid Image")
     * @ORM\Column(name="TYPETHUMBNAIL", type="string", length=500, nullable=true)
     */
    private $typethumbnail;
 
    /**
     * @var \Producttype
     *
     * @ORM\ManyToOne(targetEntity="Producttype")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="ARBORESCENCEID", referencedColumnName="ID",onDelete="CASCADE")
     * })
     */
    private $arborescenceid;
 
 
 
    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }
 
    /**
     * Set producttypename
     *
     * @param string $producttypename
     * @return Producttype
     */
    public function setProducttypename($producttypename)
    {
        $this->producttypename = $producttypename;
 
        return $this;
    }
 
    /**
     * Get producttypename
     *
     * @return string 
     */
    public function getProducttypename()
    {
        return $this->producttypename;
    }
 
    /**
     * Set typethumbnail
     *
     * @param string $typethumbnail
     * @return Producttype
     */
    public function setTypethumbnail($typethumbnail)
    {
        $this->typethumbnail = $typethumbnail;
 
        return $this;
    }
 
    /**
     * Get typethumbnail
     *
     * @return string 
     */
    public function getTypethumbnail()
    {
        return $this->typethumbnail;
    }
 
    /**
     * Set arborescenceid
     *
     * @param \Project\CRMBundle\Entity\Producttype $arborescenceid
     * @return Producttype
     */
    public function setArborescenceid(\Project\CRMBundle\Entity\Producttype $arborescenceid = null)
    {
        $this->arborescenceid = $arborescenceid;
 
        return $this;
    }
 
    /**
     * Get arborescenceid
     *
     * @return \Project\CRMBundle\Entity\Producttype 
     */
    public function getArborescenceid()
    {
        return $this->arborescenceid;
    }
 
 
    public function __toString()
    {return $this->producttypename;}
 
 
 
 
 
      public function getFullPath() {
        return null === $this->typethumbnail ? null : $this->getUploadRootDir(). $this->typethumbnail;
    }
 
    protected function getUploadRootDir() {
        // the absolute directory path where uploaded documents should be saved
        return $this->getTmpUploadRootDir().$this->getId()."/";;
    }
 
    protected function getTmpUploadRootDir() {
        // the absolute directory path where uploaded documents should be saved
        return __DIR__ . '/../../../../web/Products/Thmbn1/';
    }
 
    /**
     * @ORM\PrePersist()
     * @ORM\PreUpdate()
     */
    public function uploadTypethumbnail() {
        // the file property can be empty if the field is not required
        if (null === $this->typethumbnail) {
            return;
        }
        if(!$this->id){
            $this->typethumbnail->move($this->getTmpUploadRootDir(), $this->typethumbnail->getClientOriginalName());
        }else{
            $this->typethumbnail->move($this->getUploadRootDir(), $this->typethumbnail->getClientOriginalName());
        }
        $this->setTypethumbnail($this->typethumbnail->getClientOriginalName());
    }
 
    /**
     * @ORM\PostPersist()
     */
    public function moveTypethumbnail()
    {
        if (null === $this->typethumbnail) {
            return;
        }
        if(!is_dir($this->getUploadRootDir())){
            mkdir($this->getUploadRootDir());
        }
        copy($this->getTmpUploadRootDir().$this->typethumbnail, $this->getFullPath());
        unlink($this->getTmpUploadRootDir().$this->typethumbnail);
    }
 
    /**
     * @ORM\PreRemove()
     */
    public function removeTypethumbnail()
    {
        unlink($this->getFullPath());
        rmdir($this->getUploadRootDir());
    }
 
 
 
 
 
}

Maintenant je vous propose le show.html.twig de producttype:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{% extends 'ProjectCRMBundle:Account:layout.html.twig' %}
 
{% block content %}
 
 
				<div class="n_ok"><p>
 
 
  <strong>Product type Show</strong> </p>           
 </div>  
 
</br>	
<div class="full_w">
<table>
<th>	</th>	<th>	</th>  <th>	</th>	<th>	</th>
<th>	</th>   <th>	</th>  <th>	</th>	<th>	</th>
<th>	</th>   <th>	</th>  <th>	</th>	<th>	</th>
<th>	</th>   <th>	</th>  <th>	</th>	<th>	</th>
<th>	</th>   <th>	</th>  <th>	</th>	<th>	</th>
<th>	</th>	<th>	</th>  <th>	</th>	<th>	</th>
<th>	</th>   <th>	</th>  <th>	</th>	<th>	</th>
<th>	</th>   <th>	</th>  <th>	</th>	<th>	</th>
<th>	</th>   <th>	
 
	<th><form action="{{ path('producttype_delete', { 'id': entity.id }) }}" method="post">
            <input type="hidden" name="_method" value="DELETE" />
            {{ form_widget(delete_form) }}
            <input  type="image" SRC="{{ asset('bundles/ProjectCRM/img/supprimer.png')}}" onclick="return confirm('Are you sure you want to delete this item  ?');" border:0 />
 
        </form>
</th>	
 
 
 
	<th> <a   href="{{ path('producttype_edit', { 'id': entity.id }) }}" >
<IMG SRC="{{ asset('bundles/ProjectCRM/img/i_edit1.png')}}"  href="{{ path('producttype_edit', { 'id': entity.id }) }}" ALT="Editer"  TITLE="Editer">
</a>	</th>	
 
 
 
 
        <th>    <a class="icon add_page"  href="{{ path('producttype') }}">
<IMG SRC="{{ asset('bundles/ProjectCRM/img/precedent1.png')}}"  href="{{ path('producttype') }}" ALT="Back to the list"  TITLE="Back to the list">
</a> </th>
 
 
</table >
 
 
 
    <table class="record_properties">
        <tbody ALIGN=LEFT>
            <tr>
                <th>Id</th>
                <td>{{ entity.id }}</td>
            </tr>
            <tr>
                <th>Category Name</th>
                <td>{{ entity.producttypename }}</td>
            </tr>
            <tr>
                <th>Thumbnail</th>
                <td> <img src="{{ asset('Products/Thmbn1/' ~ entity.id ~'/' ~ entity.typethumbnail)}}" alt="photo medecin" height="38" width="58" /></td>
            </tr>
        </tbody>
    </table>
 
     </div>   
{% endblock %}