Page 1 of 1

Finding a tmp file on a virtual host

Posted: Thu Oct 14, 2010 1:10 pm
by jaceinla
Hi everyone!

First post here. I would imagine this would be pretty simple for most veterans, but since I'm under a year with PHP, I've snagged myself on this little problem. I have a work around (though the Zend Framework I'm using) but I'd really like to take out a few lines of code to knock out that work around.

This is a simple file upload. I'm uploading an image. Once the image is uploaded, I'm sending it over to Amazon's S3 Database (if your unfamiliar with it, it's just a simple DB that is used by Amazon that you can share).

So what's the problem?

Well I don't want that image to be "move_uploaded_file" since it is going to be stored on Amazon. So naturally I'll just grab the $_FILES['image']['tmp_name'] and then move that right? (it gets renamed before it is uploaded through a Zend Amazon Service class) Well that was my plan, however, since I'm testing this on a virtual host, I run into a problem...

The tmp path is /Applications/MAMP/htdocs/my/tmp/image

Now if I want to display the tmp image right away, or send it over to Amazon, the file path is appended to the virtual host...eg...

If I <img src> it, it will look for the image at http://example/Applications/MAMP/htdocs/my/tmp/image instead of /Applications/MAMP/htdocs/my/tmp/image
Same with uploading it to Amazon (the image does not show up)

Is there a built in function that can ignore the VH and get the image wherever it is?

Thanks!

Re: Finding a tmp file on a virtual host

Posted: Thu Oct 14, 2010 5:29 pm
by requinix
jaceinla wrote:Is there a built in function that can ignore the VH and get the image wherever it is?
No. Just do a move_uploaded_file to whatever publicly-accessible location you want.

But why do you need an <img> if all you're doing is uploading to S3?

Re: Finding a tmp file on a virtual host

Posted: Thu Oct 14, 2010 7:26 pm
by jaceinla
But why do you need an <img> if all you're doing is uploading to S3?
I don't, just using it as an example for how the recently uploaded files were being treated. Thanks for the info, I figured I'd have to move it around, but it seems like it's more of a 'problem' with a local host + virtual host on the same 'server', oh well! :D Thanks again