4

I have created a PHP script to upload a file, unfortunately I don't have permission to save files on the disk. I have to upload an excel file (using phpexcel), then I have to read all the rows in the file and save to disk, Is there any way for me to process this file without saving to disk, I tried to read $_FILES['file1']['tmp_name'] but it doesn't work.

could u please suggest a method to process this file

Thank you for the consideration

apaderno
  • 28,547
  • 16
  • 75
  • 90
john
  • 535
  • 7
  • 23
  • 2
    You are not allowed to save data anywhere on the server? Why? That sounds like a misconfiguration. – Pekka Aug 07 '10 at 10:02
  • 1
    You need to be more specific. Programming is all about the details. As Pekka says, tell us why you " don't have permission to save files on the disk". Also, when you say " it doesn't work." how doesn't it work? Please describe its behaviour, listing any error messages or other output. Help us to help you. – APC Aug 08 '10 at 08:14

3 Answers3

4

By "save to disk" you mean to send it back to the user for him to download it?

Usually, you shall have write access to (at least) the PHP temporary directory. Have you tried whether the form and script work in a local environment? Maybe there is something elso wrong with the upload?!

Finally: Why so you not have the persmission to save files? Are you allowed to create a subdirectory below you PHP file (via FTP) and give that one full permissions?

BurninLeo
  • 4,240
  • 4
  • 39
  • 56
  • 1
    +1: The "why" is an important question here. This sounds like a serious misconfiguration. – Pekka Aug 07 '10 at 10:04
2

I tried to read $_FILES['file1']['tmp_name']

most probably you have just encountered an error.
that happens to beginner programmers very often

you have to repair that error instead of looking for odd workarounds.
Start from checking $_FILES['file1']['error']

what does

var_dump($_FILES['file1']['error']);

say?

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
  • 1
    The "newbie programmers" comment is maybe not by everyone's taste, but this is a very constructive answer. Why the downvote? – Pekka Aug 07 '10 at 10:31
  • if a word "newbie" sounds rude, I'm open to change it to any politically correct term. – Your Common Sense Aug 07 '10 at 10:34
  • I personally don't think it's rude, but maybe somebody overly sensitive did. That, or a revenge downvoter. Can't do anything about those... – Pekka Aug 07 '10 at 11:01
  • 8
    I didnt downvote, but I found the general tone somewhat derogatory. Though you do not explicitly say it, the answer can be read as *"You cant get it to work, so you're a noob. And your attempt at fixing the issue is obviously stupid"*. This is quite often the case with answers and comments of yours. They carry good information, but often they come across with an elitist attitude. Apparently, I'm not the only thinking so because I find them flagged as offensive in the Moderator Tools quite often. It's just that I have accepted Col Shrapnel uses words like Shrapnel and dont bother. – Gordon Aug 07 '10 at 11:21
  • 1
    I see nothing wrong with this post in its current form. I think its also very constructive to point out that a mistake is made by many new / inexperienced programmers. To me, that reads "Don't feel bad, many people just learning make the same mistake", so +1. – Tim Post Aug 09 '10 at 12:07
0

Instead of sending your files with a form (multidata over HTTP POST), you can send your files with a little bit of Javascript with the HTTP PUT method to your server.

This scenario is described in the official documentation of PHP -> PUT method support.

Due some restrictions described in the documentation you have to do some workarounds to be able to work it properly.

You can read the direct input stream from your Webserver. The data will be piped from your Webserver to your PHP programm and will be only saved in memory. To do a PUT Ajax call with jQuery was answered here. You can use a jQuery upload plugin like Uploadify.

Community
  • 1
  • 1
DrDol
  • 2,220
  • 2
  • 19
  • 23