# Error en upload image into server

**URL:** <https://www.ruby-forum.com/t/error-en-upload-image-into-server/179108>\
**Category:** Rails\
**Created:** [November 17, 2009, 9:53pm UTC](https://www.ruby-forum.com/t/error-en-upload-image-into-server/179108 "2009-11-17T21:53:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![laura\_cordoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ccd318/32.png) [@laura\_cordoba](https://www.ruby-forum.com/u/laura_cordoba)\
**Post date:** [November 17, 2009, 9:53pm UTC](https://www.ruby-forum.com/t/error-en-upload-image-into-server/179108/1 "2009-11-17T21:53:17Z")

</div>

Hello, I have a problem with upload file into server, the server machine  
have Debian and the application is running with Apache2. My problem is  
that I can’t upload a photo in the site (the site is running in the 80  
port and I have passenger in the server), and when I run “ruby  
script/server” to depurate error and I try to upload file into server, I  
can upload file correctly(this is in the 3000 port).  
I don’t have idea to solved this problem, I am trying to solve this  
problem for 3 weeks. If anyone can help I would appreciate that.

This is my function in the model to upload file

def mount\_image  
filename = self.image  
extension = File.extname(filename.to\_s)  
if [‘.jpg’, ‘.png’, ‘.gif’].include?(extension)  
path =  
“/var/www/apps/playerpress.com/public/users/#{self.id}/user\_image/”  
FileUtils.mkdir\_p(path)  
img\_file = File.join(path+filename)  
if File.exist?(img\_file)  
File.delete(img\_file)  
end

```
  File.open(img_file,'wb') do |file| file.write(self.image.read) end

```

end  
end

In the controller I have this

def update  
@user = User.find(params[:id])  
old\_image = @user.image  
path\_file = @user.path\_image.to\_s+old\_image.to\_s  
# guardamos el usertype del usuario que se estÃ¡ por modificar  
old\_usertype = @user.usertype  
respond\_to do |format|  
if @user.update\_attributes(params[:user])  
if @user.image.to\_s ==""  
@user.update\_attributes({:image =\> old\_image})  
else  
if old\_image != @user.image  
if File.exist?(path\_file)  
File.delete(path\_file)  
end

```
        @user.mount_image
      end
    end
  end

```

end

And the view I have this line

PictureClick here to browse\<%= f.file\_field :image %\>

---

<div class="post-metadata">

**Author:** ![laura\_cordoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ccd318/32.png) [@laura\_cordoba](https://www.ruby-forum.com/u/laura_cordoba)\
**Post date:** [November 18, 2009, 7:20pm UTC](https://www.ruby-forum.com/t/error-en-upload-image-into-server/179108/2 "2009-11-18T19:20:33Z")

</div>

The apache/passenger logs do not say anything special?
