lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 4 Mar 2013, at 02:41, albert wrote:

> However this example can't fulfill my requirement, I want to upload a local exist file while not a trash file.

Did it work properly with the example function?

> I change the readfunction to my code below:
> 
> c:perform({readfunction=function(n)
>  local datafilename = "mydatafile"
>  local fhandle = io.open(datafilename, "r")
>  local datafromfile = nil
>  if nil ~= fhandle then
>      datafromfile = fhandle:read("*all")
>      fhandle:close()
>  end
>  return datafromfile
>          end})

> But my code didn't work.

Can you be a bit more specific? What actually happens? Do you get an error/segfault/only part of the file?

The two things that jump out at me are:

o Are you sure fhandle is valid?
o Is the file size larger than n?

Thanks,
Kevin