Forum Moderators: coopster

Message Too Old, No Replies

Help with image function

         

walatafa

9:01 pm on Nov 29, 2014 (gmt 0)

10+ Year Member



I have a problem when i upload a pic in the ADMIN PANEL. It uploads nicely but dosent show on the page index. I get an error like

www. site.com/\http://www.site.com/uploads/other/1.png\


here is the code of the script. Kindly help me


function uploadImage() {
if (isset($_FILES["picture"]) && $_FILES["picture"]["name"] && preg_match('/\.(jpg|jpeg|gif|jpe|png|bmp)$/i', $_FILES["picture"]["name"]) && preg_match('/\.(php|asp|jsp)$/i', $_FILES["picture"]["name"]) == false) {
$time = time();
$imagename = $time . "_" . $_FILES["picture"]["name"];
$dest = "../uploads/other/";

if (file_exists($dest) == false) {
mkdir($dest);
}

copy($_FILES['picture']['tmp_name'], $dest . $imagename);
return $imagename;
} else {
return '';
}
}

walatafa

5:40 pm on Dec 2, 2014 (gmt 0)

10+ Year Member



bump /Hoping anyone saw this

penders

12:13 am on Dec 5, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



...I get an error like 
www. site.com/\http://www.site.com/uploads/other/1.png\


Well, it's difficult to know what your problem is, as your "error" doesn't seem to be related to the script you have posted?

You say it "uploads nicely". So, you have confirmed that the image is actually being uploaded correctly to your server?

If so, then it perhaps looks like your error is in the script that displays the image on the page... the script that builds the URL to display in the IMG tag? Which I assume is the malformed URL that you have posted?

$dest = "../uploads/other/";


Bit of a side issue, but this rang alarm bells just glancing over your script. Using a relative destination file path in a server-side context is going to be prone to error. You only have to move your script, or for another script to change the CWD and your script breaks.

walatafa

3:45 am on Dec 7, 2014 (gmt 0)

10+ Year Member



Thank you very very much for the reply

Just as the image wouldnt show in the help section like it should...this is what happens when i post an faq in the help section too...

Each auction ends when the timer reaches zero on sites\' servers. 

First (obviously) you\'ve got to pay for the auction\'s ending price. You may do this by clicking \"Proceed to Checkout\" at the top of the auction page, or by going to My Account and selecting Claim Now under \"Ready To Claim\". Have your payment information ready, because you\'ll enter it during the checkout process. We\'ll send you an email confirming your purchase, and another one each time your item\'s status is updated.

You must pay for your auction win within 3 days of the auction ending. If you don\'t pay for your auction within this time frame, we\'ll assume you no longer want the item. Please contact Customer Support if you have any questions!


The script automatically inserts Slashes and quotations.. I dont know wheere to look at any more either the template script or the php script (of the help.php) or maybe the admin script where i post the Faq's.?

penders

3:47 pm on Dec 10, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The script automatically inserts Slashes and quotations..


What do you mean by "quotations"?

Without seeing your script we can't say for sure what is happening. But your script is not necessarily adding slashes. Before PHP 5.4, PHP itself will automatically add slashes to submitted POST data by default. In this case, your script would need to actually remove these slashes!

(You can use stripslashes() to remove these unwanted slashes - but the script should first check that the PHP directive "magic_quotes_gpc" is enabled, this is what actually triggers the slashes to be added in the first place. The other option would be to disable this directive on your server - if indeed this is the problem.)

Incidentally, this is a different issue to your "image not displaying" problem above.

Leosghost

4:33 pm on Dec 10, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



All the backslashes appear to be in order to display "literal quote marks"' either single or double quotes)..which in many of your cases are used as commas for abbreviations-contractions ( I forget what those commas are called in English ) or possessives..

But in this sentence..
Each auction ends when the timer reaches zero on sites\' servers.

the literal quote mark-comma after sites\ should not exist..

magic quotes is (IME) always painfull ..